Skip to content
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

'login_url' filter issue with 'home_url()' #44

Open
josephclawrence opened this issue Mar 15, 2015 · 8 comments
Open

'login_url' filter issue with 'home_url()' #44

josephclawrence opened this issue Mar 15, 2015 · 8 comments

Comments

@josephclawrence
Copy link

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.

@rmccue
Copy link
Member

rmccue commented Mar 16, 2015

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?

@josephclawrence
Copy link
Author

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.

@josephclawrence
Copy link
Author

Any ideas @rmccue ?

@josephclawrence
Copy link
Author

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

@josephclawrence
Copy link
Author

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.

@rmccue
Copy link
Member

rmccue commented Mar 30, 2015

@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?

@scarstens
Copy link

@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.

login-filter-working-mercator

@josephclawrence
Copy link
Author

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 [email protected]
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants