Google は今でもあなたの味方です。
EarnestoDev から (デフォルトのロールを設定):
// 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
});
https://wordpress.stackexchange.com/questions/31791/how-do-i-programmatically-set-default-role-for-new-users
t310s から (ユーザー ロールの変更):
// 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
mike23 から (ユーザー ロールの変更):
$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
Dan Gilmore (マルチサイトで役割を変更) から:
//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/