试试这样的。另请阅读wp_redirect() 也
function redirect_by_role(){
if (is_user_logged_in()) {
$user = wp_get_current_user();
if (is_home()) {
if ( in_array( \'author\', (array) $user->roles ) ) {
$redirect_url= \'\';
wp_redirect($redirect_url, 301); exit;
}
elseif( in_array( \'**another_role_here**\', (array) $user->roles ) ) {
$redirect_url= \'\';
wp_redirect($redirect_url, 301); exit;
}
}
} else {
// Do what you want
}
}
// Add the action with maximum priority
add_action(\'init\',\'redirect_by_role\',0);