Reputation: 7866
I have a website that uses Wishlist Member to control registration and BBPress.
I can assign a role to the user upon registration for the Forums. However, I can't assign them a role for the website, which WordPress uses to allow users to access their profile at http://www.domainname.com/wp-admin/profile
Any ideas on how I can allow the users to access their profile if they wish to change their password or upload a picture etc.
I have set the role default in WordPress for new users to be 'Spectator' but when I create new users no user role is being set.
Upvotes: 1
Views: 4695
Reputation: 19435
Google is still your friend.
From EarnestoDev (Set default role):
// Hijack the option, the role will follow!
add_filter('pre_option_default_role', function($default_role){
// You can also add conditional tags here and return whatever
return 'subscriber'; // This is changed
return $default_role; // This allows default
});
Fromt t310s (Change user role):
// NOTE: Of course change 3 to the appropriate user ID
$u = new WP_User( 3 );
// Remove role
$u->remove_role( 'subscriber' );
// Add role
$u->add_role( 'editor' );
https://wordpress.stackexchange.com/questions/4725/how-to-change-a-users-role
From mike23 (change user role):
$my_user = new WP_User( $user_id );
$my_user->set_role( "editor" );
https://wordpress.stackexchange.com/questions/22962/how-to-programmatically-add-a-user-to-a-role
From Dan Gilmore (change role on multisite):
//Short version
$user_id = $result['user_id'];
$user = new WP_User($user_id);
$user->remove_role('owner');
$user->add_role('administrator');
http://dangilmore.com/blog/2011/10/19/programatically-changing-users-roles-in-wordpress-multisite/
Upvotes: 6