WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Logout to redirect to home page.

[Resolved] Logout to redirect to home page.

  • I’m trying to add a text logout button to a page that will either redirect to the homepage or the page same page instead of going to the wordpress login page.

    Spent about an hour reading through articles to no resolve.

    I’ve tried this: http://codex.wordpress.org/Function_Reference/wp_logout_url and it simply won’t display anything on the page.
    The only way I’ve managed to get the logout working is by
    <a href="http://www.url.com/wp-login.php?action=logout">Logout</a> and that redirects to the wordpress login page which I don’t want.

Viewing 2 replies - 1 through 2 (of 2 total)
  • in WP_LOGIN I just specified the URL. Hope this will work for you.

    $redirect_to = !empty( $_REQUEST[‘redirect_to’] ) ? $_REQUEST[‘redirect_to’] : ‘wp-login.php?loggedout=true’;
    wp_safe_redirect( $redirect_to );
    exit();

    $redirect_to = ‘http://www.mafclubs.com’;
    wp_safe_redirect( $redirect_to );
    exit();

    break;

    Worked brilliantly. Thank you!

    The only thing is the

    $redirect_to = 'http://www.mafclubs.com';
    wp_safe_redirect( $redirect_to );
    exit();

    Needs to sit above:

    $redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : 'wp-login.php?loggedout=true';
    wp_safe_redirect( $redirect_to );
    exit();

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Logout to redirect to home page.’ is closed to new replies.
Skip to toolbar