Redirect Users after Login – WordPress
Paste this code in your functions.php and every time any non-administrator logs in he will be redirected to the home page.
add_filter("login_redirect", "subscriber_login_redirect", 10, 3);
function subscriber_login_redirect($redirect_to, $request, $user){
if(is_array($user->roles)){
if(in_array('administrator', $user->roles)) return home_url('/wp-admin/');
}
return home_url();
}
function subscriber_login_redirect($redirect_to, $request, $user){
if(is_array($user->roles)){
if(in_array('administrator', $user->roles)) return home_url('/wp-admin/');
}
return home_url();
}
Related PostsIf you liked Redirect Users after Login – WordPress; the posts below might interest you too:
|



