-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default redirection with WP Networking #95
Comments
:) +1 |
The redirect url is now handling like this:
|
This bug is not solved. It is working bad on WPMU (aka WP Network) installs, because it is redirecting to the main site, not working on subsites. Also, it is not working for search result pages and alike. I think the problem is you are both using the wrong function to get the site URL part and you are not considering the query. I had to modify the code this way: if ( empty( $redirect_url ) ){
global $wp;
// $formatted_url = trailingslashit( add_query_arg( '', '', network_site_url( $wp->request ) ) );
if ($wp->query_string) {
$formatted_url = add_query_arg( $wp->query_string, '', home_url( $wp->request ) );
}
else {
$formatted_url = trailingslashit( add_query_arg( '', '', home_url( $wp->request ) ) );
}
}
// This is just a slug, and doesn't have http(s), so lets add it
elseif ( strpos( $redirect_url, 'http' ) === false ) {
// $formatted_url = network_site_url( $redirect_url );
$formatted_url = home_url( $redirect_url );
} Using home_url instead of network_site_url, and using $wp->query_string as an argument of add_query_arg. That way i can return even to search result pages and other custom URLs. |
There's a small bug reported via the .org forum: https://wordpress.org/support/topic/little-bug-on-default-redirection
The text was updated successfully, but these errors were encountered: