I'm trying to determine how I can redirect users upon logout, to a URL defined by their role. Simply put, I want to redirect admins (as well as editors) that logout to a different URL, than subscribers / privileged users.
I'm using the following code to redirect users at logout right now, but this redirects everyone. Any insight as to how I can have a different redirect based on their account role, would be great!
/**
* Redirect to custom login page after the user has been logged out.
*/
public function redirect_after_logout() {
$redirect_url = home_url( 'member-login?logged_out=true' );
wp_safe_redirect( $redirect_url );
exit;
}
add_action( 'wp_logout', array( $this, 'redirect_after_logout' ) );
Thanks!