Help with Login URL
 
Notifications
Clear all

Help with Login URL

6 Posts
3 Users
1 Reactions
1,824 Views
(@guillermorivr)
New Member
Joined: 5 years ago
Posts: 2
Topic starter  

Hello, I am using the WPDiscuz plugin.

I want to modify the URL of “Please LOGIN to comment”.

I have added this code in the functions.php file of my WordPress theme (Magnitude) but it doesn’t work, I am always redirected to wp-login.php.

add_filter (‘login_url’, ‘my_login_linkchanger’);
function my_login_linkchanger ($ link) {
/ * what to do with the link * /
   return home_url (‘/ login’);
}

I need your help because it is very important to change the URL for me.

Thanks and regards.


   
Quote
 Tom
(@tomson)
Famed Member Admin
Joined: 10 years ago
Posts: 4209
 

Hi @guillermorivr,

First you should have a login page. Do you have  a login page other than the default WordPress wp-login.php? If you don't have any other login page then you don't have any URL to change.

In case if you have one, and the URL of that page is example.com/my-login-page/ , the inserted code should look like this:

add_filter ('login_url', 'my_login_linkchanger');
function my_login_linkchanger ($link) {
      return home_url ('/my-login-page/');
}

   
ReplyQuote
(@guillermorivr)
New Member
Joined: 5 years ago
Posts: 2
Topic starter  

I have inserted the code at the end of the functions.php file (I see this file appears in wp-includes and in my theme directory). I modify the file that is inside the directory of my theme.

After doing this, now when I go to view the content of an article, an error appears.

Have I misplaced the code or what is happening?

Attached images.

p2

 

code

 

This post was modified 5 years ago 2 times by GuillermoRivR

   
ReplyQuote
 Tom
(@tomson)
Famed Member Admin
Joined: 10 years ago
Posts: 4209
 

@guillermorivr,

I updated the code, please change it. The wrong part was copied from your post. So that too.


   
ReplyQuote
(@guillermorivr)
New Member
Joined: 5 years ago
Posts: 2
Topic starter  

@tomson 

 

Well now, thanks! One last question, how can I be redirected to the article after login?


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

@guillermorivr,

Please remove the code provided above and use the following one and you'll be redirected to the same post page.

add_filter ('login_url', 'my_login_linkchanger');
function my_login_linkchanger ($link) {
global $post;
$redirect_to = '';
if (!empty($post->ID)) {
$redirect_to = '?redirect_to=' . get_permalink($post->ID);
}
return home_url ('/my-login-page/' . $redirect_to);
}

Save, delete all caches, and check again.


   
ReplyQuote
Share:
Scroll to top