更改注销重定向的正确方法是logout_redirect
过滤器:
/**
* Filters the log out redirect URL.
*
* @since 4.2.0
*
* @param string $redirect_to The redirect destination URL.
* @param string $requested_redirect_to The requested redirect destination URL passed as a parameter.
* @param WP_User $user The WP_User object for the user that\'s logging out.
*/
add_filter( \'logout_redirect\', function( $redirect_to, $requested_redirect_to, $user ) {
if ( ! $requested_redirect_to ) { // Don\'t override the redirect if one was already set in the logout URL
$redirect = home_url( user_trailingslashit( \'my-account\' ) );
}
return $redirect;
}, 10, 3 );