From 4b79e69d890b0444e5b2adfedca50f55a6bd3421 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 7 Apr 2020 16:12:22 +0000 Subject: [PATCH] Users: Pass the ID of the user that was logged out to the `wp_logout` action. Props donmhico, figureone, TimothyBlynJacobs, rebasaurus. Fixes #49533. git-svn-id: https://develop.svn.wordpress.org/trunk@47553 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/pluggable.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php index bee11348ee..69543e88c1 100644 --- a/src/wp-includes/pluggable.php +++ b/src/wp-includes/pluggable.php @@ -573,16 +573,21 @@ if ( ! function_exists( 'wp_logout' ) ) : * @since 2.5.0 */ 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. + * 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' ); + do_action( 'wp_logout', $user_id ); } endif;