Dailythemes By Createew
SCROLL
(0)
Expert
All
How Is?
Helpers

Login Redirect For Users In WordPress

by Dailythemes Team - August 25, 2020
Login Redirect For Users In Wordpress

Login redirect for users is a expert topic. Please be careful!

Add code to your theme functions.php file

/*****************************************************************
LOGIN REDIRECT 
*****************************************************************/
function dailythemes_my_login_redirect( $url, $request, $user ) {
    if ( $user && is_object( $user ) && is_a( $user, 'WP_User' ) ) {
        if ( $user->has_cap( 'administrator' ) ) {
            $url = admin_url();
        } else {
            $url = home_url();
        }
    }
    return $url;
}
 
add_filter( 'login_redirect', 'dailythemes_my_login_redirect', 10, 3 );

That’s ok now. All users except admin will be redirected to the homepage.

TAGS

wordpress, login, redirect

dailythemes-live-support