25% off ProSNIPC25OFF

Redirect Logged-In Users Away From Login Page

Sends already-authenticated visitors to the dashboard (admins) or homepage (others) when they attempt to load the login screen.

PHPby SnipCraft
php
<?php
if ( ! function_exists( 'scseed_redirect_logged_in_from_login' ) ) {
    function scseed_redirect_logged_in_from_login() {
        if ( is_user_logged_in() ) {
            $destination = current_user_can( 'manage_options' ) ? admin_url() : home_url( '/' );
            wp_safe_redirect( $destination );
            exit;
        }
    }
    add_action( 'login_init', 'scseed_redirect_logged_in_from_login' );
}
#login#redirect#users#ux