Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Action Reference/wp logout


The wp_logout action hook is triggered when a user logs out using the wp_logout() function. The action is executed after the wp_clear_auth_cookie() function call.

This hook is an action which means that it primarily acts as an event trigger, instead of a content filter. Basic usage is as follows:

function your_function() {
    // your code
add_action('wp_logout', 'your_function');

For example, you could use it to delete a transient stored while user is logged in:

function clear_transient_on_logout() {
add_action('wp_logout', 'clear_transient_on_logout');

This hook provides no parameters.

Source File

wp_logout is located in wp-includes/pluggable.php.

See also

Plugin API - Actions, wp_login