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.