WordPress.org

Support

Support » How-To and Troubleshooting » Why does log out redirect to the log in screen?

Why does log out redirect to the log in screen?

  • Why does log out redirect to the log in screen? That’s the last place you want to go when you log out. Why not redirect to the home page?

Viewing 5 replies - 1 through 5 (of 5 total)
  • I agree. Is there a (straightforward) way to change this?

    I’m working through this myself- try wp_logout-url

    I’ve found a solution – find

    $redirect_to = ‘

      wp-login.php?loggedout=true

    ‘;
    if ( isset( $_REQUEST[‘redirect_to’] ) )
    $redirect_to = $_REQUEST[‘redirect_to’];

    and modify to

    $redirect_to = ‘

      index.php

    ‘;
    if ( isset( $_REQUEST[‘redirect_to’] ) )
    $redirect_to = $_REQUEST[‘redirect_to’];

    in /wp-login.php

    logout will take visitors to the home page.

    That would be editing core code, and I strongly urge you to NEVER do that unless there is no other recourse. Never. Ever. 🙂

    Okay? Good.

    There’s a function for this: http://codex.wordpress.org/Function_Reference/wp_logout_url

    Logout and Redirect to Current Page

    <a href="<?php echo wp_logout_url( get_permalink() ); ?>" title="Logout">Logout</a>

    Logout and Redirect to Homepage

    <a href="<?php echo wp_logout_url( get_bloginfo('url') ); ?>" title="Logout">Logout</a>

    Now this means you can’t use the default meta widget, but if you have a php executable plugin tossed in, you can get really fancy:

    <p><?php wp_loginout( get_permalink() ); ?> | <?php wp_register('', ''); ?></p>

    And so on.

    Cool – ta 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Why does log out redirect to the log in screen?’ is closed to new replies.