Trouble Changing Comment Form Fields
-
I have been using the comment_form() tag in order to customise my comments form, however I cannot seem to modify the fields.
Here is the code I have so far:
<?php $fields = array( 'author' => '<div class="field">' . '<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 . ' /></div>', 'email' => '<div class="field"><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 . ' /></div>', 'url' => '<div class="field"><label for="url">' . __( 'Website' ) . '</label>' . '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></div>', ); ?> <?php comment_form('id_form=frm-comment&title_reply=Leave a Comment Yourself&fields=' . $fields); ?>
The title and form ID change fine, but the fields do not. In fact, when I look at my form the only thing I see above the textarea element is just some text saying ‘Array’.
Does anyone know what I am doing wrong?
I think I need this line of code somewhere, but am unsure where to put it:
apply_filters( 'comment_form_default_fields', $fields )
I have tried it in both my comments.php and functions.php files but neither appear to work.
If anyone has any advice that would be great ??
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Trouble Changing Comment Form Fields’ is closed to new replies.