• Resolved formidablefemale

    (@formidablefemale)


    Hi,

    I’m trying to redirect the login page for logged in users to a custom url. I tried to use a version of the php code given in a recent answer but only received errors. Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Jeff Farthing

    (@jfarthing84)

    What is the code you are using?

    Tom

    (@tomhargreaves)

    hi there,

    you may be referring to my previous post so thought i’d give my input here.

    the reply that i received in this forum also did not work for me, but after digging around i managed to get a solution:

    add_action('wp', 'add_login_check');
    function add_login_check()
    {
        if ( is_user_logged_in() && is_page( [6070, 6071, 6072, 6073] ) ) {
            wp_redirect('https://my_homepage_url');
            exit;
        }
    }

    add this to your wordpress functions.php file.

    you then need to replace the 6070, 6071, 6072, 6073 numbers to whatever the page IDs are for your login, register, lostpassword and resetpass pages (these can be found in the URL when editing the page).

    and finally you can change the wp_redirect('https://my_homepage_url'); to whatever webpage you want the users to be redirected to.

    hope this helped.

    Thread Starter formidablefemale

    (@formidablefemale)

    Jeff, I was using the code given in Tom’s question for redirecting users a few posts down but it wasn’t working. Fortunately, he provided a solution that worked like a dream. Thanks, Tom!

    Tom

    (@tomhargreaves)

    you’re most welcome

    Hi @jfarthing84,
    1. I’m using a plugin that makes a “PRIVATE PAGE” for every user.
    2. I want to use your plugin to redirect logged users “subscribers” to they custom private page which is something like this: myurl.com/private/%username%
    3. Can I write URL with variables in your plugin? in the custom location field?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Redirect Logged In Users’ is closed to new replies.