Search
Close
AI Search
Classic Search
 Search Phrase:
 Search Type:
Advanced search options
 Search in Forums:
 Search in date period:

 Sort Search Results by:

AI Assistant
Help with Login URL
 
Notifications
Clear all

Help with Login URL

6 Posts
3 Users
1 Reactions
2,436 Views
(@guillermorivr)
New Member
Joined: 6 years ago
Posts: 2
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
  [#5863]

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: 11 years ago
Posts: 4245
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

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: 6 years ago
Posts: 2
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

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

 



   
ReplyQuote
 Tom
(@tomson)
Famed Member Admin
Joined: 11 years ago
Posts: 4245
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

@guillermorivr,

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



   
ReplyQuote
(@guillermorivr)
New Member
Joined: 6 years ago
Posts: 2
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

@tomson 

 

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



   
ReplyQuote
Elvina
(@elvina)
Support
Joined: 7 years ago
Posts: 1403
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

@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