'login_url' filter issue with 'home_url()'
josephclawrence opened this issue · comments
Hi
I have function making use of the 'login_url' filter, to use a custom user login page for sites on my network. In it I return a new login URL that I generate using the 'home_url()' function, since I determined that to be the best function to use to return the correctly mapped domain for a given site.
It doesn't work, however. My 'login_url' filter function works, since if I set it manually to another page on the site, or to google.com or something it works fine. It seems that I cannot properly use 'home_url()' (or 'site_url()' for that matter) on mapped domains when using Mercator. The function works fine for subdomains on my main network domain, just not for mapped domains.
Any ideas? Thanks.
It seems that I cannot properly use 'home_url()' (or 'site_url()' for that matter) on mapped domains when using Mercator.
I'm not sure exactly what the issue is here? Can you post the relevant part of your code (including the add_filter
call, as well as the expected/actual output of the filter?
Thanks for the reply. Here is the code:
function health_login_url( $login_url, $redirect ){
return home_url('/login');
}
add_filter( 'login_url', 'health_login_url', 10, 2);
The expected output/effect is for the user to be directed to the /login page of the site they are on, when usually they would have been directed to /wp-login.php. This works as expected on any site where it is just a subdomain on the main network domain (e.g. subdom.networkdom.com), but does not work if there is a mapped domain (e.g. mappeddomain.com, which is mapped to subdom2.networkdom.com). The function itself works, since if I use:
function health_login_url( $login_url, $redirect ) {
return 'http://google.com';
}
add_filter( 'login_url', 'health_login_url', 10, 2);
for example, then when a user would usually get directed to /wp-login.php, they would instead get directed to google.com. This means it must be something about the combination of using this filter, with Mercator active, on a site with a mapped domain. I have also tried site_url(), and get_home_url() and get_site_url(), but none of them work in this instance.
Does that make sense? Let me know if you need any other details. Thanks.
Any ideas @rmccue ?
Or if no ideas on how to solve this issue exactly, do you have any thoughts on any other Wordpress functions I could use to get the correct site URL whilst using the login_url filter?
I could imagine many people using this plugin might also want to use the login_url filter, to create custom login pages...
Thanks
Hi @rmccue I'm not expecting direct support, but could you let me know if you are unable to look at this at all, so I can decide whether or not to pursue other avenues? Thank you.
@josephclawrence Sorry for the late reply here, totally forgot!
I tried this locally, and it was working for me when I dump out wp_login_url()
on the frontend. I can't see any reason it wouldn't work either; is there a specific place you're seeing this not work? Any other details that might help?
@josephclawrence I think the updates I made in our fork (and pending pull request to official mercator) might have fixed the issue with your filter. I appled your filter after the sunrise config and it properly changed the "login url" that comes built into the wordpress core "meta" widget.
Thanks Seth, that's great news. I will have a look at this early 2016 :)
On Wed, Dec 9, 2015 at 12:35 AM, Seth Carstens notifications@github.com
wrote:
@josephclawrence https://github.com/josephclawrence I think the updates
I made in our fork (and pending pull request to official mercator) might
have fixed the issue with your filter. I appled your filter after the
sunrise config and it properly changed the "login url" that comes built
into the wordpress core "meta" widget.[image: login-filter-working-mercator]
https://cloud.githubusercontent.com/assets/1483300/11670824/4f235c0e-9dc1-11e5-979d-101147d875d8.png—
Reply to this email directly or view it on GitHub
#44 (comment).
Director
Clickshape (Pty) Ltd
www.clickshape.com
Twitter http://www.twitter.com/josephclawrence | LinkedIn
http://www.linkedin.com/in/josephclawrence | Website
http://www.clickshape.com