Last update at :2023-12-11,Edit by888u
How to set up WordPress to jump to different pages after administrator login and ordinary user login? WordPress defaults to the administrator login address and the backend login address of ordinary registered users to jump to the same interface in the backend. How to set this up? Paste the following code into the function.php file of the current WordPress theme to enable WordPress to jump to different pages according to different user pages.
function my_login_redirect($redirect_to, $request, $user){
if( is_array( $user->roles ) ) {
// Check user's role
if( in_array( "administrator", $user->roles ) ) {
// Jump to the administrator user interface
return $redirect_to;
} else {
//Jump to other user interface
return home_url();
}
}
}
add_filter("login_redirect", "my_login_redirect", 10, 3);
Friends who like it can give it a try and avoid some spam comments! If your theme itself comes with it, you don’t need to!
Recommended site searches: host rental, foreign server, Hong Kong high-defense server rental, mainland China cloud host, check IP, new network domain name registration, free host national dynamic IP, check IP, virtual host space,
发表评论