Site logo

Reply To: How to change the “login” link in the comments?

Home Forums Support How to change the “login” link in the comments? Reply To: How to change the “login” link in the comments?

Home Forums Support How to change the “login” link in the comments? Reply To: How to change the “login” link in the comments?

#1963538
Simon

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&nbsp;first&nbsp;<a href="/registration/">register</a>).</p>' 
        ),
        wp_login_url( apply_filters( 'the_permalink', get_permalink() ) )   
    );
    return $fields;
});