WordPress action hook · part of WordPress core

wp_logout

A WordPress core action that 14 plugins also fire themselves, running on 857K+ sites between them.

“Fires after a user is logged out.”

How to use wp_logout

It's an action: your callback runs at that point and receives 1 argument. Nothing needs to be returned. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_action( 'wp_logout', function( $user_id ) {
	// Your code runs here.
}, 10, 1 );

Argument names come from WP 2FA's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

This hook is fired by WordPress core too. Official reference on developer.wordpress.org →

14 plugins that fire wp_logout

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. Kadence Security icon Kadence Security700,000+ installs do_action( 'wp_logout', $current_user->ID ) core/lockout.php:866
  2. WP 2FA icon WP 2FA100,000+ installs do_action( 'wp_logout', $user_id ) includes/classes/Admin/Helpers/class-ajax-helper.php:597
  3. WP-Members Membership Plugin icon WP-Members Membership Plugin50,000+ installs do_action( 'wp_logout', $user_id ) includes/class-wp-members-user.php:198
  4. WP Remote Users Sync icon WP Remote Users Sync5,000+ installs do_action( 'wp_logout', $user->ID ) inc/api/class-wprus-api-logout.php:115
  5. MultiManager WP icon MultiManager WP2,000+ installs do_action( 'wp_logout' ) includes/class-multi-manager-wp-rest-api.php:1434
  6. Only one device login limit icon Only one device login limit200+ installs do_action( 'wp_logout' ) only-one-device-login-limit.php:282
  7. Bitcoin, Ethereum and ERC20 crypto wallets with exchange icon Bitcoin, Ethereum and ERC20 crypto wallets with exchange70+ installs do_action( 'wp_logout' ) includes/functions.php:30
  8. Password only login icon Password only login40+ installs do_action( 'wp_logout' ) index.php:92
  9. WP Similar Basic Auth icon WP Similar Basic Auth10+ installs do_action( 'wp_logout' ) includes/class-cookie.php:267
  10. Delete My Account for Ultimate Membership Pro icon Delete My Account for Ultimate Membership Pro10+ installs do_action( 'wp_logout' ) classes/Main.php:137
  11. multi-login-checker icon multi-login-checker10+ installs do_action( 'wp_logout' ) single-user-login.php:50
  12. WPCareers icon WPCareers10+ installs do_action( 'wp_logout' ) include/jp_functions.php:314
  13. TweakMaster icon TweakMasterFewer than 10 installs do_action( 'wp_logout' ) php/tweaks-standalone/enable-maintenance-mode.php:36
  14. Siri WP Security icon Siri WP SecurityFewer than 10 installs do_action( 'wp_logout' ) custom-login.php:287

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.