Hello,
Is it possible to change the login link to trigger my login popup instead of redirecting to the WP login page?
Thank you,
-Chris
Hi @chris-reilly,
Please read this support topic: https://wordpress.org/support/topic/change-link-for-login-link-text/
Hi Tom,
It kinda sounds like he wants to change the filter after the login url. How do I change the actual login url?
For example:
From: https://www.misc-site.com/wp-login.php?redirect_to=misc-link
To: https://www.misc-site.com/register/?type=login?redirect_to=misc-link
I apologize for the noob questions btw. Lots of this stuff is way over my head, but I'm trying to figure it out and learn.
Thank you,
-Chris
All is already explained in the topic. He what to do the same and put that code in your active theme functions.php file. Your code should be like this:
add_filter( 'login_url', 'my_login_linkchanger');
function my_login_linkchanger( $link ) {
return home_url( '/register/?type=login&redirect_to=misc-link' );
}
Thanks for getting back to me Tom. What would that last line look like if I wanted it to behave like it currently does? Like redirect to back to the page they were on before they signed in?
Also, by adding this code, my normal WP login page doesn't change correct?
Thank you,
-Chris
No, it doesn't affect your original login URL.
Use this code if you want to redirect back afther the login:
add_filter( 'login_url', 'my_login_linkchanger');
function my_login_linkchanger( $link ) {
global $wp;
return home_url( '/register/?type=login&redirect_to=' . urlencode( home_url( $wp->request ) ) );
}
Hi Tom,
Thanks for clarifying that my original login won't change.
I added the code you provided but I get redirected back to home after logging in. Is there anyway to redirect the user back to the post they were on prior to logging in, like it did originally?
Thank you,
-Chris
We've just checked on our test website and don't find such an issue.
It seems there is some plugin that manipulates with the redirected URL. Please deactivate the plugins one by one and check after each deactivation to find a problem maker.
Another reason: probably the custom page created by theme or the plugin redirect it to the home page immediately and ignore the redirection code provided by us.
Hi Elvina,
I just googled the last part of the code that Tom gave me and I found the link below.
https://codex.wordpress.org/Function_Reference/home_url
The original code that Tom posted didn't have the following code: . urlencode( home_url( $wp->request ) )
Based off of that link, that code suggests that the home_url would send the user back to the home page.
Is this incorrect?
-Chris
Hello Elvina,
I just played with it a bit and you're right. The code does appear to be correct. When looking at the url after clicking the login button, it does in fact show the previous pages url, BUT, the url isn't displaying correctly.
It appears like this:
Could this be why it's falling back to the home url?
Thank you,
-Chris
Okay will do. I'll start disabling plugins like you've suggested and go from there.
Thank you,
-Chris