wp_logout()WP 2.5.0

Log the current user out.

This is a pluggable function, and it can be replaced by a plugin. It means that this function is defined (works) only after all plugins are loaded (included), but before this moment this function has not defined. Therefore, you cannot call this and all functions depended on this function directly from a plugin code. They need to be called on plugins_loaded hook or later, for example on init hook.

Function replacement (override) — in a plugin you can create a function with the same name, then it replace this function.

Hooks from the function


null. Nothing.




Since 2.5.0 Introduced.

Code of wp_logout() WP 5.9.3

function wp_logout() {
	$user_id = get_current_user_id();

	wp_set_current_user( 0 );

	 * Fires after a user is logged out.
	 * @since 1.5.0
	 * @since 5.5.0 Added the `$user_id` parameter.
	 * @param int $user_id ID of the user that was logged out.
	do_action( 'wp_logout', $user_id );