Redirect Admin Users to Dashboard after login from Custom login page

function nucleo_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 = get_permalink( get_option( 'woocommerce_myaccount_page_id' ) );
        }
    }
    return $url;
}

add_filter( 'login_redirect', 'nucleo_login_redirect', 10, 3 );
add_filter( 'woocommerce_login_redirect', 'nucleo_login_redirect' );
add_filter( 'woocommerce_registration_redirect', 'nucleo_login_redirect' );

Contact me.

I would love to hear from you, send me a message using the form below.

    ×