corsonr
8/7/2012 - 8:24 AM

how to redirect a user after login

how to redirect a user after login

// Redirect admins to the dashboard and other users elsewhere
add_filter( 'login_redirect', 'xxx_login_redirect', 10, 3 );

function xxx_login_redirect( $redirect_to, $request, $user ) {
    // Is there a user?
    if ( is_array( $user->roles ) ) {
        // Is it an administrator?
        if ( in_array( 'administrator', $user->roles ) )
            return home_url( '/wp-admin/' );
        else
            return home_url();
            // return get_permalink( 83 );
    }
}