destroy_all example

$manager->destroy_others( $token );
    }
}

/** * Removes all session tokens for the current user from the database. * * @since 4.0.0 */
function wp_destroy_all_sessions() {
    $manager = WP_Session_Tokens::get_instance( get_current_user_id() );
    $manager->destroy_all();
}

/** * Gets the user IDs of all users with no role on this site. * * @since 4.4.0 * @since 4.9.0 The `$site_id` parameter was added to support multisite. * * @global wpdb $wpdb WordPress database abstraction object. * * @param int|null $site_id Optional. The site ID to get users with no role for. Defaults to the current site. * @return string[] Array of user IDs as strings. */
'message' => __( 'Could not log out user sessions. Please try again.' ),
            )
        );
    }

    $sessions = WP_Session_Tokens::get_instance( $user->ID );

    if ( get_current_user_id() === $user->ID ) {
        $sessions->destroy_others( wp_get_session_token() );
        $message = __( 'You are now logged out everywhere else.' );
    } else {
        $sessions->destroy_all();
        /* translators: %s: User's display name. */
        $message = sprintf( __( '%s has been logged out.' )$user->display_name );
    }

    wp_send_json_success( array( 'message' => $message ) );
}

/** * Handles cropping an image via AJAX. * * @since 4.3.0 */
Home | Imprint | This part of the site doesn't use cookies.