From time to time clients come to me requesting login redirects in WordPress. The following handy snippet below allows you to specify where the user lands once they’ve logged in, based on user roles. In the example, users with Administrator and Editor roles are redirected to the Dashboard, whilst everyone else gets redirected to the site’s homepage.

Add the code to your theme’s functions.php file.

function admin_login_redirect( $redirect_to, $request, $user )
{
    global $user;
    if( isset( $user->roles ) && is_array( $user->roles ) ) {
        if (( in_array( "administrator", $user->roles ) ) ||  ( in_array( "editor", $user->roles ) ) ) {
            return $redirect_to;
        } else {
            return home_url();
        }
    }
    else 
    {
        return $redirect_to;
    }
}
add_filter("login_redirect", "admin_login_redirect", 10, 3);