# Redirect to the Homepage After Logout

> Sends users to your homepage after they log out instead of showing the "You are now logged out" login screen.

- Type: PHP
- Runs: Run everywhere
- Category: [Login](https://wpide.com/library/category/login/)
- Tags: logout, redirect
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/logout-redirect-to-homepage/

## Code

```php
add_filter( 'logout_redirect', function ( $redirect_to, $requested ) {
    return $requested ? $redirect_to : home_url( '/' );
}, 10, 2 );
```

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Redirect to the Homepage After Logout" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
