That button sends an AJAX request that runs wp_ajax_destroy_sessions()
.
It’s not really abstracted in such a way that you can re-use it outside of AJAX, but if you copy the source into your own function, minus the JSON parts, then you could perform the same action yourself.
The key part is this bit, which will destroy all sessions for a given user ID:
$sessions = WP_Session_Tokens::get_instance( $user_id );
$sessions->destroy_all();
The rest of the function is just checking the user exists, checking permissions, and sending a JSON response. They might not be relevant for your use case, so the above might suffice.
Related Posts:
- Login/logout in header
- Get my site session in wordpress?
- Are there any drawbacks on opening a session_start in functions.php and header.php?
- Allow user to select location and then set cookie for location in WordPress
- How to set and use global variables? Or why not to use them at all
- Is it possible to disable a function of a parent theme?
- Hide old attachments from wp media library
- PHP – redirect https to http and www to non-www
- add_filter to post-gallery and remove all ‘s?
- Set the transport of the Customizer ‘header_image’ core setting to ‘postMessage’
- Can i check if user is doing any ajax request?
- Displaying post per day
- How to Populate the list of custom post type categories
- Php string not working in WordPress Functions.php [duplicate]
- delete an array element when its date expires
- Understanding WordPress child theme custom JS loading
- Problem with ACF shortcode with Repeater Field in WordPress? [closed]
- Why is PHP Cookie via plugin only set when logged in as Admin and not regular users? and other questions
- Insert After Second Paragraph Without Tag?
- javaScript in section of WP API
- page template for attachement page?
- WordPress Redirect: Default Password Reset URL [duplicate]
- Removing unneccessary p-tags (Not every p)
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- Showing content from one page on another
- How to insert a single row to WP database table?
- How to remove or change the “W” icon in “My Sites”?
- How to: PHP Log Out Link?
- How to add seperate classes to no-search-result and found-search-result pages on wordrpess search – is_search()
- Woocommerce: hook action/filter I could use to add variation id and price with each attribute opt on WooCommerce Rest api
- Firing schema via code in functions.php doesn’t work
- A non-numeric value encountered in /wp-includes/functions.php on line 68
- getting logged in user info (wp-load.php) from parent directory
- Blog posts repeat
- Ajax load more button for comments wordpress
- Unique icons next to each WordPress menu item
- Update user profile information from functions.php
- Add .htm extention to a custom taxonomy
- Custom gallery in wp3.5
- How can I modify footer when footer.php calls to another file?
- How to fix this warning:call_user_func_array() expects exactly 2 parameters, 1 given in D:\wamp\www\…….\wp-includes\class-wp-hook.php on line 286
- How to set the WordPress logo programmatically with PHP
- Function works everywhere, how to keep it to execute when creating a new post
- esc_url( ) won’t use https
- Function won’t run onclick using Ajax
- Add login hyperlink to secondary navigation menu
- Where is this function’s callback getting its arguments from?
- Use post ID in functions.php file adminside
- How to: Conditionally Enqueue JS and Stylesheets, for Custom Post Type (Single and Archive Templates)
- List all blogs, but exclude the main site
- $_SESSION variable not saving on page refresh or new page
- change the default order of posts only for specific categories
- Reading settings in the home page precisely home.php
- Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
- Calling function in loop causes repeat data
- Custom posts password protect
- How to get post category list as select in front-end?
- How to use functions [closed]
- Splitting the_content() by size?
- Is there a hack for using is_page() within the function.php file?
- Add a select-option to the default widgets
- Function to call either single post or category
- Updating Metadata with Shortcode
- can’t load .po file in functions.php
- WP-Bakery – Add custom colors to buttons with template colors
- Woocommerce – Exclude variation attribute on specific variation
- How do I add a function to parent theme
- Create shortcode for metabox gallery
- Show all people who commented on all posts by an author
- Log out without confirmation request (nonce)
- Add Pre-Defined Value to Click Counter in WordPress
- How can I redefine WordPress wp-content directory programmatically?
- Trim Titles Only On Some Pages
- Custom global variable not working in function
- Show data obtained from a function and place it in a shortocode function
- get_the_author_meta( ‘ID’ ) just return 1
- Delete empty title_tags, find a h1 heading and echo it
- Enqueue sripts and styles only if function is called
- Site title not showing. Please help me
- Check if post visited first time
- ajaxurl usage for a custom function
- Store custom field’s multiple values in one user meta key
- oembed facebook link?
- Open/closed function [closed]
- Need to Echo A Url path to show on a wordpress page
- add a value to an external link query in searchform
- Restrict File Type Uploads by User on Wordress via functions.php
- AJAX Returning Way Too Many Posts
- site_url() returns with additional backslashes
- Overwriting a Shortcode
- How to get category pages to look like a certain archive page?
- How to call a specific value within the functions.php file?
- Select area and checkbox data is not saving?
- Suppress errors when using global function
- Warning: Attempt to read property “term_id” on int – Woocommerce
- Warning: filemtime(): stat failed for wp_
- How to transfer session after being redirected to other page
- Keep users logged in Without Remember Me
- How to use js variable to php in wordpress functions.php
- how to create twitter card without plugin in wordpress website?