Redirect user to home after Logout in WordPress without plugin

By February 6, 2017 WordPress No Comments

How to Redirect WordPress Logout to Home Page or any other page without using plugin?

To Redirect user after logout in WordPress to your website Home page or any other page you don’t need any plugin, You can simply use a small code snippets.

This is a useful trick If you’re developing a website in WordPress and want to manually redirect users after logout of your WordPress website. By default, WordPress will redirect them to the login page of your website, but you  can easily change it by adding following snippet to current theme’s functions.php file:

Here’s an easy way to set up logout redirection to your home page or any other page instead of default login page.

 

Navigate to your theme’s functions.php. This can be found under Appearance/Editor.

Paste the following code at the bottom of your functions.php.

 

[php] function logout_redirect_home(){
wp_safe_redirect(home_url());
exit;
}
add_action(‘wp_logout’, ‘logout_redirect_home’);
[/php]

 

Same if you wish to Redirect user to a custom page after Logon in WordPress without using any plugin,  you see my another tutorial on  “Redirect Users after Login in WordPress to a custom page without using plugin“.


[paypal-donation]

About Vijay Dhanvai

A passionate blogger by heart and mind, I have been working in this field for 10 years now. A WordPress Professional, web developer and designer who intends to guide his readers about Web Design, WordPress, Blogging, Web Development, and more.

Leave a Reply