
How To Auto Redirect Users After Logout In WordPress
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(); }
Tags: Auto Redirect Users After Logout Custom logout url and redirection in Woocommerce How To Auto Redirect Users After Logout In WordPress How to redirect a Wordpress logout to custom URL logout with redirect Redirect WordPress Users in Different Situations woocommerce customer logout redirect to homepage
One thought on “How To Auto Redirect Users After Logout In WordPress”
Comments are closed.