Jump to content

Create new member programmatically?


Tom S.

Recommended Posts

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Upcoming Events

    No upcoming events found
×
×
  • Create New...