wp_logout Not Logging Me Out

wp_logout() calls clear_auth_cookie(), which expires all authorization cookies set. It doesn’t change the value of the global $current_user variable. So technically you’re still logged in for the duration of the script. If you’re using wp_logout in your own code, its probably best to exit or wp_redirect immediately afterwards. You can call wp_set_current_user(0) after wp_logout() to … Read more

Clearing cookie on logout and session expiration

Try setting $experation to a negative integer: function myplugin_cookie_expiration( $expiration, $user_id, $remember ) { return $remember ? $expiration : -600; } add_filter( ‘auth_cookie_expiration’, ‘myplugin_cookie_expiration’, 99, 3 ); From the w3schools PHP page on cookies: <?php // set the expiration date to one hour ago setcookie(“user”, “”, time()-3600); ?>

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 . ‘&amp;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 . ‘&amp;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