I was having this same issue.
wp_redirect( wp_logout_url( $foo ) );
would redirect me to /wp-login.php?action=logout& amp;redirect_to=%2Fabout%2F
.
The &
was being escaped in wp_logout_url
causing the logout action to send me along to /wp-login.php?loggedout=true
. $_REQUEST['redirect_to']
was actually $_REQUEST['& amp;redirect_to']
causing it to default to the login page. Anyway, blah blah blah, read through the source code and fixed it with a filter inside my plugin:
add_filter('logout_url', 'fix_logout_url');
function fix_logout_url( $url )
{
$url = str_replace( '& amp;', '&', $url );
return $url;
}
Basically wp_logout_url
called wp_nonce_url
which converts $amp;
to &
and then tops it off with an esc_html()
converting &
back to & amp;
. Luckily there’s a nice filter to sneak in and correct it.
Whew! Late night goose chase complete.