Archived topic
Comment form - alter_comment_form_fields
3 replies · Started by Fabio on December 29, 2021
Hy all,
I try to change default comment form but I have a strange issue.
Generatepress theme --> work correctly and I see my change
Generatepress child theme ( downloaded from here ) --> don't work .
function wpb_alter_comment_form_fields($fields) {
$fields['author'] = '<p class="comment-form-author" >' . '<label for="author">' . __( 'Name and Surname (Required)' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
'<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>';
// Modify Email Field and show that it's Optional
$fields['email'] = '<p class="comment-form-email" style="font-weight: bold;"><label for="email">' . __( 'Email (Required)', 'twentythirteen' ) . '</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>';
return $fields;
}
add_filter('comment_form_default_fields', 'wpb_alter_comment_form_fields');`
edit : other php snippet work in child theme. Only this for comment form not work.
Have you any idea ?
thanks
Hi Fabio,
On this line:
add_filter('comment_form_default_fields', 'wpb_alter_comment_form_fields');
Can you try modifying it to this?
add_filter('comment_form_default_fields', 'wpb_alter_comment_form_fields', 99, 1);
And see if it works.
Great Elvin !!! work's like a charm!
thanks for your support
No problem. Glad you got it sorted.
Happy new year! :D