- This topic has 7 replies, 5 voices, and was last updated 4 years, 5 months ago by
Leo.
-
AuthorPosts
-
September 19, 2020 at 11:41 am #1450246
andres
How to change the “login” link in the comments?
ThankSeptember 19, 2020 at 4:56 pm #1450402David
StaffCustomer SupportHi there,
what change do you want to make to it?
September 20, 2020 at 12:13 pm #1451369andres
I need to change the link for “logged in” to a user log in url instead of wp login url.
September 20, 2020 at 7:29 pm #1451553Elvin
StaffCustomer SupportHi,
Did you mean this link?

You can use
login_urlfor that. – https://developer.wordpress.org/reference/hooks/login_url/You can try adding this PHP code.
add_filter( 'login_url', 'my_login_linkchanger'); function my_login_linkchanger( $link ) { $link = '?page_id=2'; return $link; }Just change
?page_id=2value to your page slug. Ex:about/,login/,my-account/Let us know if it works for you.
September 21, 2020 at 11:07 am #1452687andres
Perfect, thanks!
What should I do to change the text “you must be logged in to post a comment”September 21, 2020 at 11:39 am #1452721Leo
StaffCustomer SupportOctober 14, 2021 at 9:35 am #1963538Simon
Thanks for the link above. Just to add a solution –
I found the PHP code three comments above meant that the user did not return to the original page after login. That is really tedious for the user, and will prevent comments. So we had to accept that it had to go to the backend login.
However, with the code you linked to, I could (1) change from the Askimet wording as we wanted, and (2) add a custom registration link, while just keeping the backend login. (I customised the backend.) The code snippet is:
/* Modify the "must_log_in" string of the comment form. * @see http://wordpress.stackexchange.com/a/170492/26350 */ add_filter( 'comment_form_defaults', function( $fields ) { $fields['must_log_in'] = sprintf( __( '<p class="must-log-in"><a href="%s">Login</a> to comment (or first <a href="/registration/">register</a>).</p>' ), wp_login_url( apply_filters( 'the_permalink', get_permalink() ) ) ); return $fields; });October 14, 2021 at 10:15 am #1963568Leo
StaffCustomer SupportThanks!
-
AuthorPosts
- You must be logged in to reply to this topic.