latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Create User Via Front-End

Home Forums Community Forum Create User Via Front-End

Tagged: , ,

This topic contains 1 reply, has 2 voices. Last updated by  Cristián Lávaque 3 years, 10 months ago.

Topic Author Topic
Posted: Friday Feb 22nd, 2013 at 11:26 am #42841
Angela Zou
Username: angelaz

I would like to be able to add a user via front-end form that I have created, this is my code and somehow it’s not working as it’s suppose to. Btw, am I suppose to set the capability for can_access_levelx as well?

$new_user = new WP_User('', $username);
var_dump($new_user);
$new_user->set_user_email = $email;
$new_user->set_role = $role;
wp_new_user_notification( $new_user->get_ID );

//Here is the result of my var_dump		
object(WP_User)#280 (7) {
	["data"]=> NULL
	["ID"]=> int(0)
	["caps"]=> array(0) { }
	["cap_key"]=> NULL
	["roles"]=> array(0) { }
	["allcaps"]=> array(0) { }
	["filter"]=> NULL
}

List Of Topic Replies

Viewing 1 replies (of 1 total)
Author Replies
Author Replies
Posted: Sunday Feb 24th, 2013 at 7:47 am #43090

Hi Angela.

You’re doing the var_dump before adding the other values.

And you seem to be using the methods incorrectly. For example, the role would be set like this:

[hilite pre_code]
$new_user->set_role($role);
[/hilite]

Knowledge Base » Changing Roles/Capabilities via PHP

I hope that helps. :)

Viewing 1 replies (of 1 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.