• Resolved tech55541

    (@tech55541)


    Hello,
    When this Log In or Log Out link is clicked, i would like users to be redirected to a p[age. Here is my code so far.

    <?php wp_loginout(); ?>

    So how do i redirect to a url? Is it something like this?

    <?php wp_loginout($redirect (http://yourtechadvisors.com/chat)); ?>

    Thanks for your help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter tech55541

    (@tech55541)

    So i came up with this code. It redirects to the same page on log out just not on log in.

    <?php
    if ( is_user_logged_in() ) {
    echo '<a href="'.wp_logout_url( get_permalink() ).'" title="Logout">Log Out</a>';
    } else {
    echo '<a href="'.wp_login_url( get_permalink() ).'" title="Login">Log In</a>';
    }
    ?>

    If someone could tell me how to redirect the page to where they logged in from which is http://yourtechadvisors.com/chat this code would be perfect.

    Thanks.

    Thread Starter tech55541

    (@tech55541)

    Had to remove ?> from the code and it worked. Also had to clear cache.

    Hope this helps anyone in the same situation.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘PHP Code Log In Log Out Redirect’ is closed to new replies.