How to add custom comment fields but *only on the comment reply form*?

I’ve been searching high and low for this but can’t find anything that explains how to add custom fields to only the reply form. I’ve seen and got working custom fields on the comment form, but when a user clicks reply, I want to have a different set of fields. Better still a different set of fields depending on the reply level.

Here’s what I’m trying to do.

Suppose you have a site which posts a blog entry that you want people to post reviews and comments as a first level comment. I’d add a custom field for the first level comment with the options (radio button or drop down): “Review”, “Comment”. That’s easy enough to do and well documented.

Then for 2nd level replies I want people to be post a comment that says whether they agree or disagree with that review and why, or just make a comment, so I want add a field to second level replies that has the options: “Agree”, “Disagree”, “Comment”, but the custom field on the first level comment (with “Reivew”, “Comment”) should not be displayed. This is what I can’t figure out or find any tips on nor can I find any hooks/filters that allow you to access the reply form.

I looked at this question (that seems similar) but couldn’t figure out what was done and so can’t tell if it’s a solution:
Customize reply form different to comment form

Any help greatly appreciated.

2 Answers
2

By using comment_form( $args, $post_id ) you can add extra field in your comment form like this

$commenter = wp_get_current_commenter();
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
$fields =  array(
    'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . '</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' ) . '</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>',
);

$comments_args = array(
    'fields' =>  $fields
);


comment_form($comments_args);

also Customizing Comments fields

Leave a Comment