1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Logout Link on External Site

Discussion in 'XenForo Development Discussions' started by LPH, May 5, 2016.

  1. LPH

    LPH Well-Known Member

    This is the link built to logout externally from XenForo. This works wonders. At the same time, I'm wanting to add in code for destroying WordPress session_tokens.

    PHP:
    <?php echo '<a class="xenword_logout logout" href="' XenForo_Link::buildPublicLink('canonical:logout'$visitor, array( '_xfToken' => $visitor['csrf_token_page'], 'redirect' => $redirect) ) . '">Logout</a>'?>
    Run separately:

    PHP:
    $visitor XenWord::getVisitor();
    $user_id $visitor['user_id'];

    // get all sessions for user with ID $user_id
    $wp_sessions WP_Session_Tokens::get_instance($user_id);
    // we have got the sessions, destroy them all!
    $wp_sessions->destroy_all();

    Should I create a method with the $sessions information and call it from within the form by changing the logout link to a form? Something like:

    Code:
    <input type="hidden" name="redirect" value="<?php echo $wp_sessions ?>" />
    
    Maybe it's better to use javascript at this point? (in which case, yikes).
     

Share This Page