Logout Link on External Site

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).
 
Back
Top Bottom