是的,这是可能的。您可以使用login_redirect 筛选以执行此操作。
在活动主题中使用以下代码functions.php
文件
function my_login_redirect( $redirect_to, $request, $user ) {
//is there a user to check?
global $user;
if( isset( $user->roles ) && is_array( $user->roles ) ) {
//check for contributors
if( in_array( "contributor", $user->roles ) ) {
// redirect them to the home page $home_url should contain the home page url
return $home_url;
} else {
return $redirect_to;
}
} else {
return $redirect_to;
}
}
add_filter("login_redirect", "my_login_redirect", 10, 3);