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