User Registration

  1. Home
  2. Docs
  3. User Registration
  4. How to?
  5. How to Redirect to a Specific Page after Logout?

How to Redirect to a Specific Page after Logout?

After your users log out from their accounts on your site, you need to redirect them to a certain page. It may be the homepage of your site or, any other page.

To redirect the users after they log out, you need to add a small piece of code to the functions.php of your active theme.

For this, go to your admin dashboard, and click on Appearances -> Theme Editor. Now, you’ll see the list of files on the right which includes the Theme Functions (functions.php).

In the functions.php file, simply add the code below:

add_action( 'wp_logout', 'ur_redirect_after_logout');

function ur_redirect_after_logout(){
         wp_redirect( home_url() );
         exit();
}
Was this article helpful to you? Yes 3 No 6

How can we help?