Forums
Home / Fixing WordPress / Add new field in Comment box
(@rahathaider)
10 years, 9 months ago
I am trying to add new field in the comment form by using filters.
here is my code
function add_comment_fields($fields) { $fields['age'] = '<p class="comment-form-age"><label for="age">' . __( 'Age' ) . '</label>' . '<input id="age" name="age" type="text" size="30" /></p>'; return $fields; } add_filter('comment_form_default_fields','add_comment_fields');
i also check for the filter and hook reference and found that comment_form_default_fields is empty. My question is that how can i add or remove fields in comment form.
(@scott_mcmillan)
This is a good article on how it is done. http://wp.smashingmagazine.com/2012/05/08/adding-custom-fields-in-wordpress-comment-form/
You will need an action to save the data see the save comment meta data in the article.
(@rahathaider)
10 years, 9 months ago
I am trying to add new field in the comment form by using filters.
here is my code
i also check for the filter and hook reference and found that comment_form_default_fields
is empty.
My question is that how can i add or remove fields in comment form.