[Resolved] Comment form – alter_comment_form_fields

Home Forums Support [Resolved] Comment form – alter_comment_form_fields

Home Forums Support Comment form – alter_comment_form_fields

  • This topic has 3 replies, 2 voices, and was last updated 3 weeks ago by Elvin.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2063345
    Fabio

    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

    #2063490
    Elvin
    Staff
    Customer Support

    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.

    A wise man once said:
    "Have you cleared your cache?"

    #2063583
    Fabio

    Great Elvin !!! work’s like a charm!
    thanks for your support

    #2068212
    Elvin
    Staff
    Customer Support

    No problem. Glad you got it sorted.

    Happy new year! 😀

    A wise man once said:
    "Have you cleared your cache?"

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.