您需要为此添加两次\\u操作。用户注册时一个&;第二,当用户尝试登录时。
function wpse_149067( $user_id ) {
if ( user_can( $user_id, \'tutor\' ) )
update_user_meta($user_id, \'verified_user\', false);
if ( user_can( $user_id, \'student\' ) )
update_user_meta($user_id, \'verified_user\', true);
}
add_action( \'wp_login\', \'wpse_149067_check_user\', 10, 2);
function wpse_149067_check_user($user_login, $user){
$user_id = $user->ID;
if ( current_user_can( $user_id, \'tutor\' ) && false == get_user_meta($user_id, \'verified_user\') ) {
// Do your stuff here
// eg: echo \'Please verify your account \';
}
}
?>