Notifications
Clear all

Possible to change login link?

12 Posts
3 Users
0 Likes
1,906 Views
(@chris-r)
Member Customer
Joined: 4 years ago
Posts: 53
Topic starter  

Hello, 

 

Is it possible to change the login link to trigger my login popup instead of redirecting to the WP login page?

 

Selection 006

 

Thank you,

 

-Chris


   
Quote
 Tom
(@tomson)
Famed Member Admin
Joined: 9 years ago
Posts: 4168
 

Hi @chris-reilly,

Please read this support topic: https://wordpress.org/support/topic/change-link-for-login-link-text/


   
ReplyQuote
(@chris-r)
Member Customer
Joined: 4 years ago
Posts: 53
Topic starter  

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


   
ReplyQuote
 Tom
(@tomson)
Famed Member Admin
Joined: 9 years ago
Posts: 4168
 

@chris-r

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' );
}

   
ReplyQuote
(@chris-r)
Member Customer
Joined: 4 years ago
Posts: 53
Topic starter  

@tomson

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

This post was modified 4 years ago by ChrisR

   
ReplyQuote
 Tom
(@tomson)
Famed Member Admin
Joined: 9 years ago
Posts: 4168
 

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 )  ) );
}

   
ReplyQuote
(@chris-r)
Member Customer
Joined: 4 years ago
Posts: 53
Topic starter  

@tomson

 

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

 

This post was modified 4 years ago by ChrisR

   
ReplyQuote
Elvina
(@elvina)
Support
Joined: 5 years ago
Posts: 1403
 

@chris-r,

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.


   
ReplyQuote
(@chris-r)
Member Customer
Joined: 4 years ago
Posts: 53
Topic starter  

@elvina

 

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

 


   
ReplyQuote
(@chris-r)
Member Customer
Joined: 4 years ago
Posts: 53
Topic starter  

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

This post was modified 4 years ago 2 times by ChrisR

   
ReplyQuote
Elvina
(@elvina)
Support
Joined: 5 years ago
Posts: 1403
 

@chris-r,

This is not the issue, please don't worry about this.

 


   
ReplyQuote
(@chris-r)
Member Customer
Joined: 4 years ago
Posts: 53
Topic starter  

@elvina

 

Okay will do.  I'll start disabling plugins like you've suggested and go from there.  

 

Thank you,

-Chris

 


   
ReplyQuote
Share:
Scroll to top