The default comment form fields are defined like so:
$fields = array(
'author' =>
'<p class="comment-form-author"><label for="author">' . __( 'Name', 'domainreference' ) . '</label> ' .
( $req ? '<span class="required">*</span>' : '' ) .
'<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) .
'" size="30"' . $aria_req . ' /></p>',
'email' =>
'<p class="comment-form-email"><label for="email">' . __( 'Email', 'domainreference' ) . '</label> ' .
( $req ? '<span class="required">*</span>' : '' ) .
'<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) .
'" size="30"' . $aria_req . ' /></p>',
'url' =>
'<p class="comment-form-url"><label for="url">' . __( 'Website', 'domainreference' ) . '</label>' .
'<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) .
'" size="30" /></p>',
);
And they are passed through a filter:
'fields' => apply_filters( 'comment_form_default_fields', $fields )
So to modify them, you can just add a filter:
function wpse126157_comment_form_fields( $fields ) {
// Your code here
// Return something
return $fields;
}
add_filter( 'comment_form_default_fields', 'comment_form_default_fields' );
Note the important information in the Codex:
Note: To use the variables present in the above code in a custom
callback function, you must first set these variables within your
callback using:$commenter = wp_get_current_commenter(); $req = get_option( 'require_name_email' ); $aria_req = ( $req ? " aria-required='true'" : '' );
So you can modify your callback accordingly:
function wpse126157_comment_form_fields( $fields ) {
// Include these if you intend to use them
$commenter = wp_get_current_commenter();
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
// Your code here
// Return something
return $fields;
}
add_filter( 'comment_form_default_fields', 'comment_form_default_fields' );