Some of my users have mentioned that my site is confusing for them. As this is the case, I would like to actually make links to Login/Register for my unregistered visitors to quickly do so if they would like to leave a comment.
Right now it just says “You must be logged in to post a comment.” with no link to Login. Where can I edit this and change it to “You must Register or Login to post a comment.” with links to them?
You can try to modify it with the comment_form_defaults
filter:
/**
* 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">
You must <a href="https://wordpress.stackexchange.com/questions/170490/%s">Register</a> or
<a href="https://wordpress.stackexchange.com/questions/170490/%s">Login</a> to post a comment.</p>'
),
wp_registration_url(),
wp_login_url( apply_filters( 'the_permalink', get_permalink() ) )
);
return $fields;
});
where we use the wp_registration_url()
and wp_login_url()
core functions.
ps: the info on the comment_form_defaults
filter seems to be missing from the Codex.