Meeting the Future by Making Ideas Fly

Quirk redirect after login | WordPress.org

Dec 2, 2019 | Training & Learning, Website Work Items

function loginRedirect( $redirect_to, $request, $user ) {

if ( is_a( $user, ‘WP_User’ ) && $user->has_cap( ‘edit_posts’ ) === false ) {

return get_bloginfo( ‘siteurl’ );

}

return wp_safe_redirect( wp_get_referer() );}

add_filter( ‘login_redirect’, ‘loginRedirect’, 10, 3 );

In this case the link in the page that point to “wp-login.php” redirect directly to the current page and the user haven’t the possibility to log-in.

Source: Quirk redirect after login | WordPress.org