# Return to the Main Site After Logging Out

> Sends users to the network's main homepage when they log out from any site, giving the whole network one consistent exit point.

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

## Code

```php
if ( ! is_multisite() ) {
    return;
}

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

## Notes

Change network_home_url( '/' ) to a specific page path if you prefer.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Return to the Main Site After Logging Out" 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/
