Skip to main content
after testing the old code, I found this to be the correct filter needed for the rest of this too work. Modifying at the request of someone else trying to use this question.
Source Link

Filter 'login_redirect'.

Sample code, not tested:

add_filter( 'login_redirect''wp_login', 'wpse_78150_login_redirect' );

function wpse_78150_login_redirect( $url )
{
    # uncomment the next line for debugging
    # var_dump( wp_get_current_user() ); exit;

    if ( ! current_user_can( 'custom_role' ) )
        return $url;

    return admin_url();
}

Filter 'login_redirect'.

Sample code, not tested:

add_filter( 'login_redirect', 'wpse_78150_login_redirect' );

function wpse_78150_login_redirect( $url )
{
    # uncomment the next line for debugging
    # var_dump( wp_get_current_user() ); exit;

    if ( ! current_user_can( 'custom_role' ) )
        return $url;

    return admin_url();
}

Filter 'login_redirect'.

Sample code, not tested:

add_filter( 'wp_login', 'wpse_78150_login_redirect' );

function wpse_78150_login_redirect( $url )
{
    # uncomment the next line for debugging
    # var_dump( wp_get_current_user() ); exit;

    if ( ! current_user_can( 'custom_role' ) )
        return $url;

    return admin_url();
}
added 107 characters in body
Source Link
fuxia
  • 107.1k
  • 38
  • 255
  • 459

Filter 'login_redirect'.

Sample code, not tested:

add_filter( 'login_redirect', 'wpse_78150_login_redirect' );

function wpse_78150_login_redirect( $url )
{
    # uncomment the next line for debugging
    # var_dump( wp_get_current_user() ); exit;

    if ( ! current_user_can( 'custom_role' ) )
        return $url;

    return admin_url();
}

Filter 'login_redirect'.

Sample code, not tested:

add_filter( 'login_redirect', 'wpse_78150_login_redirect' );

function wpse_78150_login_redirect( $url )
{
    if ( ! current_user_can( 'custom_role' ) )
        return $url;

    return admin_url();
}

Filter 'login_redirect'.

Sample code, not tested:

add_filter( 'login_redirect', 'wpse_78150_login_redirect' );

function wpse_78150_login_redirect( $url )
{
    # uncomment the next line for debugging
    # var_dump( wp_get_current_user() ); exit;

    if ( ! current_user_can( 'custom_role' ) )
        return $url;

    return admin_url();
}
Source Link
fuxia
  • 107.1k
  • 38
  • 255
  • 459

Filter 'login_redirect'.

Sample code, not tested:

add_filter( 'login_redirect', 'wpse_78150_login_redirect' );

function wpse_78150_login_redirect( $url )
{
    if ( ! current_user_can( 'custom_role' ) )
        return $url;

    return admin_url();
}