Conditional redirection with logout

The wp_logout() function is pluggable. You should be able to write your own version and “overload” the Core function: function wp_logout() { $lid = get_current_user_id(); wp_destroy_current_session(); wp_clear_auth_cookie(); do_action( ‘wp_logout’ ); /** * Fires after a user is logged-out. * * @since 1.5.0 */ if (2 == $lid) { wp_redirect(home_url(“/redirectTo”)); exit; } }

wp_logout problem

You could create a custom Page template which contains only the logout code, no call to header.php etc. When you load the /member-logout/ page you’re probably calling the default page.php template which is loading header.php etc. If instead you apply your custom Page template it will just perform the logout action and can then redirect, … Read more