Logout Link on External Site


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 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:

$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!

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:

<input type="hidden" name="redirect" value="<?php echo $wp_sessions ?>" />

Maybe it's better to use javascript at this point? (in which case, yikes).
Top Bottom