WordPress.org

Ready to get started?Download WordPress

Forums

Why does log out redirect to the log in screen? (6 posts)

  1. modifiedcontent
    Member
    Posted 4 years ago #

    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?

  2. FarmerFred
    Member
    Posted 4 years ago #

    I agree. Is there a (straightforward) way to change this?

  3. WilliamJames
    Member
    Posted 3 years ago #

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

  4. WilliamJames
    Member
    Posted 3 years ago #

    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.

  5. 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.

  6. WilliamJames
    Member
    Posted 3 years ago #

    Cool - ta :)

Topic Closed

This topic has been closed to new replies.

About this Topic