Title: logout_redirect
Published: April 23, 2015
Last modified: August 20, 2026

---

# apply_filters( ‘logout_redirect’, string $redirect_to, string $requested_redirect_to, WP_User $user )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/logout_redirect/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/logout_redirect/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/hooks/logout_redirect/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/logout_redirect/?output_format=md#user-contributed-notes)

Filters the log out redirect URL.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/logout_redirect/?output_format=md#parameters)󠁿

 `$redirect_to`string

The redirect destination URL.

`$requested_redirect_to`string

The requested redirect destination URL passed as a parameter.

`$user`[WP_User](https://developer.wordpress.org/reference/classes/wp_user/)

The [WP_User](https://developer.wordpress.org/reference/classes/wp_user/) object
for the user that’s logging out.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/logout_redirect/?output_format=md#source)󠁿

    ```php
    $redirect_to = apply_filters( 'logout_redirect', $redirect_to, $requested_redirect_to, $user );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-login.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-login.php#L825)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-login.php#L825-L825)

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/logout_redirect/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.2.0](https://developer.wordpress.org/reference/since/4.2.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/logout_redirect/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 3 content](https://developer.wordpress.org/reference/hooks/logout_redirect/?output_format=md#comment-content-5500)
 2.    [Gabor Lippert](https://profiles.wordpress.org/lunule/)  [  5 years ago  ](https://developer.wordpress.org/reference/hooks/logout_redirect/#comment-5500)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Flogout_redirect%2F%23comment-5500)
     Vote results for this note: -1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Flogout_redirect%2F%23comment-5500)
 4.  Logout function (that actually works) according user role:
 5.      ```php
         function wpdocs_logout_redirect( $redirect_to, $requested_redirect_to, $user ) {
     
             $user_roles = $user->roles;
             $user_has_admin_role = in_array( 'administrator', $user_roles );
     
         	if ( $user_has_admin_role ) :
         		$redirect_to = admin_url();
         	else:
         		$redirect_to = home_url();
         	endif;
     
         	return $redirect_to;
         }         
         add_filter( 'logout_redirect', 'wpdocs_logout_redirect', 9999, 3 );
         ```
     
 6.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Flogout_redirect%2F%3Freplytocom%3D5500%23feedback-editor-5500)
 7.   [Skip to note 4 content](https://developer.wordpress.org/reference/hooks/logout_redirect/?output_format=md#comment-content-3059)
 8.    [mikelast](https://profiles.wordpress.org/mikelast/)  [  8 years ago  ](https://developer.wordpress.org/reference/hooks/logout_redirect/#comment-3059)
 9.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Flogout_redirect%2F%23comment-3059)
     Vote results for this note: -4[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Flogout_redirect%2F%23comment-3059)
 10. _taken from the article at sourcexpress.com/logout\_redirect-filter-hook-introduced-
     in-wordpress-4-2_
 11. This filter comes with 3 parameters, `string $redirect_to` The redirect destination
     URL, ` string $requested_redirect_to ` The requested redirect destination URL 
     passed as parameter, ` WP_User $user ` [WP_User](https://developer.wordpress.org/reference/classes/wp_user/)
     object for the user logging out.
 12. Using the third param we can target specific redirect locations depending on the
     user, user role etc.
 13.     ```php
         function se_logout_redirect( $redirect_to, $requested_redirect_to, $user ) {
         	if ( in_array( 'subscriber', $user->roles ) ) {
         		$requested_redirect_to = home_url();
         	} else {
         		$requested_redirect_to = home_url( '/hello-world' );
         	}
     
         	return $requested_redirect_to;
     
         }
         add_filter( 'logout_redirect', 'se_logout_redirect', 10, 3 );
         ```
     
 14.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Flogout_redirect%2F%3Freplytocom%3D3059%23feedback-editor-3059)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Flogout_redirect%2F)
before being able to contribute a note or feedback.