Logout URL performing strange

This happens because of a missing nonce parameter in the URL. Every WordPress action, including login/logout, validates the nonce first, to make sure the request comes from a known source.

Logout redirect to current page – function

Using this code in the functions.php does the trick: function wpse_44020_logout_redirect( $logouturl, $redir ) { return $logouturl . ‘&redirect_to=’ . get_permalink(); } add_filter( ‘logout_url’, ‘wpse_44020_logout_redirect’, 10, 2 ); Note – The above code works only on non-admin pages. To make this work on any page you should replace: return $logouturl . ‘&redirect_to=’ . get_permalink(); With: … Read more

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. wp_set_password($new_password, $user->ID); // Log-in again. wp_set_auth_cookie($user->ID); wp_set_current_user($user->ID); do_action(‘wp_login’, $user->user_login, $user); Note that since you are setting a new log-in cookie (i.e. changing … Read more

Destroy user sessions based on user ID

OK, simple solution after digging in the WordPress code. // get all sessions for user with ID $user_id $sessions = WP_Session_Tokens::get_instance($user_id); // we have got the sessions, destroy them all! $sessions->destroy_all(); This will log the user with ID $user_id out of WordPress. Use case: My use case for this is when a user is approved … Read more

How to log out without confirmation ‘Do you really want to log out?”?

This happens because you are missing the neccessary nonce in the URL, which is being checked in wp-login.php case ‘logout’ : check_admin_referer(‘log-out’); … Use wp_logout_url in order to retreive the URL including the nonce. If you want to redirect to a custom URL, simply pass it as an argument. <a href=”https://wordpress.stackexchange.com/questions/67336/<?php echo wp_logout_url(“/redirect/url/goes/here’) ?>”>Log out</a> … Read more