logout_redirect filter hook introduced in WordPress 4.2


WordPress has almost three major updates a year and with WordPress 4.2 there has been a couple of interesting addition and updates.

A series of interesting hooks are also updated or introduced with each version. With WordPress 4.2, logout_redirect filter hook was introduced.

This filters comes with three parameters
$redirect_to (string) The redirect destination URL.
$requested_redirect_to (string) The requested redirect destination URL passed as a parameter.
$user (WP_User) The WP_User object for the user that’s logging out.

Now using the third parameter you can redirect user to different pages or section basing on their role(s).

You can do this by doing something like below

This checks if the logging out user is a subscriber and if yes redirecting it to home page else to the hello world post.

Start using this hook and let me know if you have any questions in the comments below.


Maruti Mohanty

I am a happy go lucky WordPress Developer, who loves biking, movies and learning different languages


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: