Automatically Redirect WordPress Users After Logout

Redirect WordPress Users After Logout image
WordPress is the Blogging and Content Management System with lots of  facilities provided.
If you have a multi-user WordPress site or using it as Community and allow users to register on your site, you can use this code snippet to redirect users to your website or  specific url.
For this we will use wp_redirect() function.

Uses of Auto Redirect

You can redirect your users after logout to Home Page or a page that contains offers for them or display a "Thank You for being with us" or a "heading out stay connected" message like Facebook and give a url to your Mobile Site or Mobile App.
The uses of this method are endless and this depends on your creativity.
Below is the code which you will need to paste in the functions.php file of your theme.

Redirect User to Home Page

add_action('wp_logout','auto_redirect_logout');
function auto_redirect_logout(){
  wp_redirect( home_url() );
  exit();
}

Redirect user to custom URL

add_action('wp_logout','auto_redirect_custom');
function auto_redirect_custom(){
  wp_redirect( 'http://www.techforty.com' );
  exit();
}

If this wordpress tutorial worked for you feel free to share and also comment, and if you have any queries lets talk in comments.

Comments

Popular posts from this blog

Show Full Post on Front Page of Ghost, Not Excerpt

Video Blogger Templates

5 Beautiful Dark Blogger Templates