Force logout when role is changed

The wp_login hook you are using only triggers when a user login, while we need to trigger function when user changed their role. The correct for this will be set_user_role hook. Please update your code with the given code so User will logout on changing the role. function logout_pending_users( $user_id, $new_role, $old_roles ) { // … Read more

Logout button in menu without “wp” in links

You can use wp_logout_url() function for logout link. It will automatically add nonce to the url. Try this code: add_action(‘template_redirect’, function() { if (empty($_SERVER[‘REQUEST_URI’])) return; $uri = $_SERVER[‘REQUEST_URI’]; if (preg_match(‘#^/log-out/?$#’, $uri, $matches) === 1) { $logout_url = str_replace(‘&’, ‘&’, wp_logout_url()); wp_safe_redirect($logout_url); die; } }); If you do not want to use wp_logout_url(), then try to … Read more

techhipbettruvabetnorabahisbahis forumuedueduedusedueduseduseduedueduedus