Skip to main content
31 votes

How to log out without confirmation 'Do you really want to log out?"?

If you can't use wp_logout_url() function, You can turn off this validation using this code: add_action('check_admin_referer', 'logout_without_confirm', 10, 2); function logout_without_confirm($...
Дмитрий Шишов's user avatar
28 votes

Logout redirect to home page

add_action('wp_logout','auto_redirect_after_logout'); function auto_redirect_after_logout(){ wp_safe_redirect( home_url() ); exit; } This will do the trick.
Sharif Mohammad Eunus's user avatar
13 votes

How to log out without confirmation 'Do you really want to log out?"?

If you create a custom link in your menu, set the label to “Logout”, and set the URL to http://yourdomain.com/wp-login.php?action=logout. Then add this function to your functions.php file: function ...
Gufran Hasan's user avatar
9 votes

How change wordpress password without logout ( need for plugin )

If you are changing the password for the current logged-in user, it will log you out. You have to log in again: // Get current logged-in user. $user = wp_get_current_user(); // Change password. ...
liviucmg's user avatar
  • 209
5 votes
Accepted

How to log out everywhere else, destroy all sessions "all other devices"?

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 ...
Jacob Peattie's user avatar
4 votes

How to log out without confirmation 'Do you really want to log out?"?

If you're using roots/sage wordpress starter theme, or any other theme using Laravel's Blade templating engine, make sure not to escape the url: // don't do <a href="{{ wp_logout_url(...
jnaklaas's user avatar
  • 161
4 votes

How to log out without confirmation 'Do you really want to log out?"?

This worked for me by adding /?customer-logout=true at the end. http://www.website.com/?customer-logout=true
Stanley Tan's user avatar
3 votes

How to log out everywhere else, destroy all sessions "all other devices"?

I know this is an old topic but destroy_all() will destroy all sessions but destroy_others() destroys all sessions except the current session Destroy all sessions: $sessions = WP_Session_Tokens::...
Hossein's user avatar
  • 31
3 votes

Deleting cookie to logout

Is there something additional that wp_logout does? As I said in my comment, WordPress runs two functions on wp_logout. wp_destroy_current_session() wp_clear_auth_cookie() wp_clear_auth_cookie() ...
N00b's user avatar
  • 2,169
3 votes

Woocommerce, prevent login after registration and redirect to custom URL

Try this, It may helpful. function wc_custom_registration_redirect() { wp_logout(); wp_destroy_current_session(); return home_url('/'); } add_action('woocommerce_registration_redirect', '...
Kirtan's user avatar
  • 141
2 votes

How to change the default logout link on WordPress Admin

This worked for me redirecting to the home page: add_action('wp_logout','unlog'); function unlog(){ wp_redirect( site_url() ); exit(); }
jilt's user avatar
  • 51
2 votes

Logout via Subdomain, non-wordpress page on a different server?

Assuming you are the administrator of both sites... Add admin ajax handler in your main wp site... add_action( 'wp_ajax_logout', 'my_logout_callback' ); function my_logout_callback() { wp_logout(...
shramee's user avatar
  • 477
2 votes

Is there any way to check for user login and send him to login?

When a user logs out the current user session is destroyed and no new pages can be loaded for which a user must be logged in. However, when you hit the 'back' button on your browser, it typically ...
cjbj's user avatar
  • 14.6k
2 votes

Logout using link (without nonce)

This will disable nonce checking for logging out - on your head be it: add_action( 'login_form_logout', function () { $user = wp_get_current_user(); wp_logout(); if ( ! empty( $_REQUEST[...
TheDeadMedic's user avatar
  • 36.5k
2 votes

wp_logout not redirecting using wp_logout_url() and wp_redirect()

The correct method for changing the logout redirect is the logout_redirect filter: /** * Filters the log out redirect URL. * * @since 4.2.0 * * @param string $redirect_to The redirect ...
TheDeadMedic's user avatar
  • 36.5k
2 votes

Set Short Automatic Logout Time for One User

One approach can be to log the time a user is logging in at by using: function user_last_login($user_login, $user) { update_user_meta($user - > ID, 'last_login', time()); } add_action('wp_login'...
user6552940's user avatar
2 votes

Logout without confirmation and SAME window on mobile

Try using wp_redirect($url). See https://developer.wordpress.org/reference/functions/wp_redirect/ . So...something like: // set up the URL to redirect to $redirect_to = 'https://www.example.com/page'...
Rick Hellewell's user avatar
2 votes

wp_logout() changes in WordPress 5.1.1

A lot has changed in 5.1/5.1.1, but the changes I'm seeing in WordPress core wouldn't cause 302 redirects on their own. 1. wp_logout is pluggable wp_logout is a pluggable function. That means ...
MikeNGarrett's user avatar
  • 2,661
2 votes
Accepted

Logout redirects to a broken page(home URL is omitted)

Found the answer. It is a bug in WordPress v5.2.3 affecting WordPress in Windows environments. Caused by backslashes in Windows paths that aren't stripped correctly Details here: https://core.trac....
Nat's user avatar
  • 171
2 votes
Accepted

wp_logout_url() redirects to confirmation page even with nonce?

After testing and reading the codes of WordPress. Here is the explanation of the phenomenon. Firstly, the following is nonce explanation and how it is going to affect the process. According to ...
西門 正 Code Guy - JingCodeGuy's user avatar
2 votes

Getting User email on logout. wp_logout

wp_get_current_user() will never work in this hook, because, wp_logout action fires after user is logged out: session destroyed, cookies cleared and current user is set to 0. But wp_logout action ...
anton's user avatar
  • 1,033
2 votes

Force logout ALL users at a certain time

This should be possible, WordPress provides the WP_Session_Tokens class to manage logged in sessions. Then it's just a matter of connecting it to the cron. The following is a simple plugin file which ...
Tim's user avatar
  • 401
1 vote
Accepted

How would I hook into `clear_auth_cookie` to return the user's ID that's currently being logged out?

That action doesn't pass that data: function return_user_data_on_logout( $user ) { Here, $user will alway be undefined. Additionally, you need to tell add_action how many parameters the function ...
Tom J Nowell's user avatar
  • 59.6k
1 vote

Logout redirects to default page

See https://codex.wordpress.org/Function_Reference/wp_logout_url , where you can define where you want to be redirected after a logout.
Rick Hellewell's user avatar
1 vote

share login/logout sessions across two installs?

In addition to TheDeadMedic's answer, both sites must share the same keys and salts in the wp-config.php files (I replaced the string with four zeros): define('AUTH_KEY', '0000'); define('...
TEKFused's user avatar
1 vote

How to Show Different Menus to Logged in Users in WordPress

Create defferent menus in admin panel. Go to header.php and create condition, where you need change menus. Search wp_nav_menu() function and wrap into like this condition: if(is_user_logged_in()){ ...
Maxim Sarandi's user avatar
1 vote

add the user name to menu when user is logged in

You have an errors in $items.= //Change Password, Logout, etc and $items.= //Sign up, Lost Password you haven`t value for assign.Set something into $items variable or delete this strings and all ...
Maxim Sarandi's user avatar
1 vote
Accepted

Logout Redirect and also WP-login.php Redirect

you can do that with this code (paste it to your functions.php) function auto_redirect_external_after_logout(){ // check if user is leaving from admin // is_admin() check would not work here ...
Levi Dulstein's user avatar
1 vote

Is there any way to check for user login and send him to login?

Just some appendix to @cjbj answer. It may help you, this is why I am writing this. WordPress "session" is actually a cookie. It starts with wordpress_logged_in Once you log out: Once you refresh ...
prosti's user avatar
  • 4,283
1 vote

wp_logout not redirecting using wp_logout_url() and wp_redirect()

You need to hook it to wp_logout actions hook and remove the wp_logout(); from the function. It'll look like below- add_action('wp_logout', 'wc_registration_redirect'); function ...
CodeMascot's user avatar
  • 4,527

Only top scored, non community-wiki answers of a minimum length are eligible