Support » Plugin: User registration & user profile - Profile Builder » Redirect If Already Logged In

  • Resolved Jamz

    (@jamz)



    Hi Guys,

    Is it possible if the person is already logged in, and they visit the login page again, that they are automatically redirected to the redirect url?

Viewing 1 replies (of 1 total)
  • Hi,

    Thank you for reaching out to us.

    With some custom code we can redirect the logged in user if he access the Login page:

    1. Create an empty plugin like this: https://gist.github.com/sareiodata/76f701e01db6685829db
    2. Add the following code to the end of it:

    /*
     * Redirect the logged in user to Homepage if accessing the Login page
     */
    
    add_action( 'template_redirect', 'redirect_to_specific_page' );
    
    function redirect_to_specific_page() {
    
        if ( is_page('login') && is_user_logged_in() ) {
    
            wp_redirect( 'http://www.yourdomain.com/page');
            exit;
        }
    }

    3. If your Login page is not named Login please modify the custom code accordingly. Also add inside wp_redirect() the desired URL.

    4. Install this plugin via FTP (copy it inside wp-content/plugins) or create a zip archive with it and install it via the WordPress plugin upload functionality

    Let me know if the custom code works for you.

    Best regards,

Viewing 1 replies (of 1 total)
  • The topic ‘Redirect If Already Logged In’ is closed to new replies.