function modify_comment_form_fields($fields){
// Check if $fields is an array
if (!is_array($fields)) {
return $fields;
}
ob_start();
$submit_button = ob_get_clean();
$submit_button .= '<input name="submit" type="submit" id="submit" class="submit" value="Post Comment">';
// Check if $submit_button is a string
if (!is_string($submit_button)) {
return $fields;
}
$fields['submit_field'] = $submit_button;
return $fields;
}
add_filter('comment_form_submit_field', 'modify_comment_form_fields');
The submit button is wrapped under the p
tag inside a WordPress comment form.
I wanted to get rid of this → <p class="form-submit"></p>
But the solution didn't work, Can someone help me to take this further in troubleshooting?
Currently, In browser the output of submit button is rendered as this one →
<p class="form-submit"><input name="submit" type="submit" id="submit" class="submit" value="Post Comment"> <input type="hidden" name="comment_post_ID" value="8" id="comment_post_ID">
<input type="hidden" name="comment_parent" id="comment_parent" value="0">
</p>
Update The comment form looks like this →
$fields = array(
'heading_tag' => '<h6>Leave an opinion</h6>',
'comment_field' => '<textarea name="comment" id="comment" cols="30" rows="6" placeholder="Your opinion matters, but do not spam us!" required></textarea>',
'author' => '<input type="text" name="author" placeholder="Enter Full Name" value="' . esc_attr( $commenter['comment_author'] ) . '" required>',
'email' => '<input type="text" name="email" placeholder="Enter Email ID" value="' . esc_attr( $commenter['comment_author_email'] ) . '" required>'
);
$comment_args = array(
'title_reply' => '',
'fields' => $fields,
'comment_field' => $fields['comment_field'],
'class_submit' => 'submit',
'label_submit' => 'Post Comment',
'class_form' => 'comform'
);
comment_form($comment_args);