/** Login Redirect **/
add_filter("login_redirect", "my_login_redirect", 10, 3);
function my_login_redirect( $redirect_to, $request, $user ){
    //is there a user to check?
    if( is_array( $user->roles ) ) {
        //check for admins
        if( in_array( "administrator", $user->roles ) || in_array( "editor", $user->roles ) ||  in_array( "author", $user->roles ) ) {
            // redirect them to the default place
            return admin_url();
        } else {
            return home_url('page-slug');
        }
    }
}
Advertisements