wp_logout

The timeline below displays how wordpress function wp_logout has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Logs the current user out.
 *
 * @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.
     *
     * @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);
}

WordPress Version: 5.5

/**
 * Log the current user out.
 *
 * @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.
     *
     * @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);
}

WordPress Version: 5.3

/**
 * Log the current user out.
 *
 * @since 2.5.0
 */
function wp_logout()
{
    wp_destroy_current_session();
    wp_clear_auth_cookie();
    wp_set_current_user(0);
    /**
     * Fires after a user is logged-out.
     *
     * @since 1.5.0
     */
    do_action('wp_logout');
}

WordPress Version: 4.0

/**
 * Log the current user out.
 *
 * @since 2.5.0
 */
function wp_logout()
{
    wp_destroy_current_session();
    wp_clear_auth_cookie();
    /**
     * Fires after a user is logged-out.
     *
     * @since 1.5.0
     */
    do_action('wp_logout');
}

WordPress Version: 3.9

/**
 * Log the current user out.
 *
 * @since 2.5.0
 */
function wp_logout()
{
    wp_clear_auth_cookie();
    /**
     * Fires after a user is logged-out.
     *
     * @since 1.5.0
     */
    do_action('wp_logout');
}

WordPress Version: 3.7

/**
 * Log the current user out.
 *
 * @since 2.5.0
 */
function wp_logout()
{
    wp_clear_auth_cookie();
    do_action('wp_logout');
}