Here is a useful trick If you’re trying to developing a WordPress website .And you would like to manually redirect users after logout of your WordPress website. As a default, WordPress will redirect them to the WordPress login (http://www.test.com/wp-login.php) page on your website. In this tutorial we will show you how can easily change it by adding following snippet to current theme’s functions.php
file:
add_action('wp_logout','auto_redirect_after_logout'); function auto_redirect_after_logout(){ wp_redirect( home_url() ); exit(); }
Using above code user will redirect to the homepage of your website. If You want to define define custom URL or external URL you can get this done easily. Find the following snippet below:
add_action('wp_logout','auto_redirect_external_after_logout'); function auto_redirect_external_after_logout(){ wp_redirect( 'http://wpdevcodes.com' ); exit(); }