WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How can I redirect WP Logout page to Homepage (4 posts)

  1. rossiback
    Member
    Posted 1 year ago #

    Hi, Thanks for replying, please can you in any way help me with directions on how to redirect wp logout page to to homepage? I have seen the followings but i did know how or where exactly to paste it:

    Logout and Redirect to Current Page

    <a>" title="Logout">Logout</a>

    Logout and Redirect to Homepage

    <a>" title="Logout">Logout</a>

    Again, Thank you!

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code has been permanently damaged/corrupted by the forum's parser.]

    [No bumping. If it's that urgent, consider hiring someone.]

  2. birgire
    Member
    Posted 1 year ago #

    if you want to go directly to the frontpage when you logout, place this into your functions.php in your current theme directory:

    add_action('wp_logout','go_home');
    function go_home(){
      wp_redirect( home_url() );
      exit();
    }
  3. birgire
    Member
    Posted 1 year ago #

    if you have php >= 5.3 then you can write it in more compact way, by using an anonymous function:

    add_action('wp_logout',create_function('','wp_redirect(home_url());exit();'));

  4. rossiback
    Member
    Posted 1 year ago #

    Thank you birgire, you make my day!

Topic Closed

This topic has been closed to new replies.

About this Topic