New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing User's Role #335

Closed
rahmanusta opened this Issue Jun 28, 2014 · 2 comments

Comments

Projects
None yet
4 participants
@rahmanusta

Hi, when i created a user with WP API, it has subscriber role. How can i edit its role?

@aryanduntley

This comment has been minimized.

Show comment
Hide comment
@aryanduntley

aryanduntley Jun 28, 2014

To adjust role, you can either set a default role in WP admin or you can hook into the pre insert hook like so (and make sure you pass the data and access it with the correct name, make param name whatever you wish):

function need_to_add_roles($user, $data){ $user->role = $data['user_role']; return $user; } add_filter( 'json_pre_insert_user', 'need_to_add_roles', 10, 2);

To adjust role, you can either set a default role in WP admin or you can hook into the pre insert hook like so (and make sure you pass the data and access it with the correct name, make param name whatever you wish):

function need_to_add_roles($user, $data){ $user->role = $data['user_role']; return $user; } add_filter( 'json_pre_insert_user', 'need_to_add_roles', 10, 2);

@pippinsplugins

This comment has been minimized.

Show comment
Hide comment
@pippinsplugins

pippinsplugins Aug 1, 2014

Contributor

Seems to be that role should be a supported parameter for the user create call.

Contributor

pippinsplugins commented Aug 1, 2014

Seems to be that role should be a supported parameter for the user create call.

@pippinsplugins pippinsplugins added Enhancement and removed Review labels Aug 1, 2014

@rmccue rmccue added this to the 1.2 milestone Aug 21, 2014

@rmccue rmccue closed this in #392 Aug 29, 2014

rmccue added a commit that referenced this issue Aug 29, 2014

Merge pull request #392 from WP-API/set-role-with-user
Add support for passing the role parameter to insert_user() method. #335
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment