On this page
wp_logout()
Logs the current user out.
Source
File: wp-includes/pluggable.php. View all references
function wp_logout() {
$user_id = get_current_user_id();
wp_destroy_current_session();
wp_clear_auth_cookie();
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 );
}
Hooks
- do_action( 'wp_logout',
int $user_id ) -
Fires after a user is logged out.
Related
Uses
| Uses | Description |
|---|---|
| wp_destroy_current_session() wp-includes/user.php | Removes the current session token from the database. |
| wp_clear_auth_cookie() wp-includes/pluggable.php | Removes all of the cookies associated with authentication. |
| wp_set_current_user() wp-includes/pluggable.php | Changes the current user by ID or name. |
| do_action() wp-includes/plugin.php | Calls the callback functions that have been added to an action hook. |
| get_current_user_id() wp-includes/user.php | Gets the current user’s ID. |
Changelog
| Version | Description |
|---|---|
| 2.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_logout