Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted September 13, 20186 yr Is there a class/function I can use to create a new member programmatically? So, I pass in the necessary parameters, such as display name, email, password, etc. And it creates an account?
September 13, 20186 yr Example I use in one of my resources: $password = \IPS\Login::generateRandomString( 8 ); $member = new \IPS\Member; $member->name = 'Name'; $member->email = 'something@domain.com'; $member->setLocalPassword( $password ); $member->member_group_id = 3; $member->save();
September 13, 20186 yr Author 1 minute ago, Adriano Faria said: Example I use in one of my resources: $member = new \IPS\Member; $member->name = 'Name'; $member->email = 'something@domain.com'; $member->members_pass_salt = \IPS\Member::loggedIn()->members_pass_salt; $member->members_pass_hash = \IPS\Member::loggedIn()->members_pass_hash; $member->member_group_id = 3; $member->save(); Thank you so much. A few questions if you do not mind: 1. Does this method create a random password? Or what exactly is going on with the password part? 2. How do you set a secondary group value? 3. Do you know how to set "Send confirmation email" to either true or false?
September 13, 20186 yr I edited my post above. - Random password: $password = \IPS\Login::generateRandomString( 8 ); $member->setLocalPassword( $password ); Or you can use: $member->setLocalPassword( $values['password'] ); Or even a hardcoded value: $member->setLocalPassword( '123456' ); - Secondary groups: $member->mgroup_others = implode( ',', $groupsArray ); - Confirmation email: $member->members_bitoptions['validating'] = TRUE; This will put the new member under validation and will (probably) send the email. Is that what you asked regarding confirmation email?
September 24, 20186 yr You can alternatively use the REST API to create a new member. https://invisioncommunity.com/developers/rest-api?endpoint=core/members/POSTindex
September 24, 20186 yr Author 52 minutes ago, bfarber said: You can alternatively use the REST API to create a new member. https://invisioncommunity.com/developers/rest-api?endpoint=core/members/POSTindex Very useful to know, thanks.
Archived
This topic is now archived and is closed to further replies.