I have edited wordpress login redirect for non admin user to the home page with the help of an article found via google. But in that article it used function to direct to the home page of site not URL. But I want to redirect on a specific page of my project. The code I have used is
function admin_login_redirect( $redirect_to, $request, $user )
{
global $user;
if( isset( $user->roles ) && is_array( $user->roles ) ) {
if( in_array( "administrator", $user->roles ) ) {
return $redirect_to;
} else {
return home_url();
}
}
else
{
return $redirect_to;
}
}
add_filter("login_redirect", "admin_login_redirect", 10, 3);
How do I redirect to a specific page...
@James Jones demand here is the solution
you can use get_permalink( page_id )
in place of home_url()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.