How to change a user’s role?
I have custom roles in my setup and I want to be able to automatically change a user’s role thru a function. Say user A has a SUBSCRIBER role, how do I change it to EDITOR? When adding a role we just:
add_role( $role_name , $role_display_name , array( 'read' => true, 'edit_posts' => false, 'delete_posts' => false, ));
How about changing a role? Is there something like:
I think this one will do:
$wp_user_object = new WP_User($current_user->ID); $wp_user_object->set_role('editor');