WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Login redirection not working. Am I doing it right? (4 posts)

  1. hilj
    Member
    Posted 3 years ago #

    Hello,

    I'm trying to redirect after login (and logout) but with no success :( It just goes to the backend.

    Here's my code:

    <?php
      if (is_user_logged_in()) {
        echo '<a href="' . wp_login_url( get_permalink(5) ) . '">Logout<span></span></a>';
      } else {
        echo '<a href="' . wp_logout_url( get_permalink('home') ) . '">Login<span></span></a>';
    } ?>

    All help is very much appreciated, thaks :)

  2. Reuben Gunday
    Member
    Posted 3 years ago #

    Maybe this will work....

    <?php
    echo '<a href="'.wp_logout_url(get_bloginfo('url')).">Logout<span></span></a>';
  3. hilj
    Member
    Posted 3 years ago #

    Thanks, but no :(

    It just redirects me straight back to the home page, not even showing the login form. No matter is it: get_permalink(5) or bloginfo('url')

    The link it outputs is: http://example.dev:8888/example/wp-login.php?action=logout&redirect_to=http%3A%2F%2Fexample.dev%3A8888%2F&_wpnonce=a0a724313f

  4. hilj
    Member
    Posted 3 years ago #

    Works! Sorry for the last one :)

    And thanks!!!!!

Topic Closed

This topic has been closed to new replies.

About this Topic