Site logo

[Support request] comment form

Home Forums Support [Support request] comment form

Home Forums Support comment form

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #2532341
    Srini

    Hi

    When I click Tab in the form fileds, cursor jumping to email from name field by skipping the phone number filed.
    Can you guide me to fix this issue?

    Please check the link attached.

    #2532352
    Fernando
    Customer Support

    Hi Srini,

    It’s not skipping the Phone Number field from my end when I try tabbing.

    Can you try using a different device to test?

    #2532376
    Srini

    Hi Fernando,

    Please check below video.

    #2532388
    Srini

    Hi Fernando,

    Please check below video.

    #2532395
    Fernando
    Customer Support

    I see. May we know how you specifically added the Phone Number field?

    #2532408
    Srini

    Yes, added additional filed

    #2532419
    Fernando
    Customer Support

    Can you specify how you added it? What steps did you take for that field to appear?

    #2532442
    Srini

    I have edited the commnet.php file and included additional field

    $fields[‘author’] = sprintf(
    ‘<label for=”author” class=”screen-reader-text”>%1$s</label><input placeholder=”Name *” id=”author” name=”author” type=”text” value=”%2$s” size=”30″%4$s />’,
    esc_html__( ‘Name’, ‘generatepress’ ),
    esc_attr( $commenter[‘comment_author’] ),
    $required ? ‘ *’ : ”,
    $required ? ‘ required’ : ”
    );

    $fields[‘phone’] = sprintf(
    ‘<input placeholder=”%1$s%3$s *” id=”phone” name=”phone” type=”text” value=”%2$s” size=”30″%4$s />’,
    esc_html__( ‘Phone’, ‘generatepress’ ),
    esc_attr( $commenter[‘comment_author_phone’] ),
    $required ? ‘ ‘ : ”,
    $required ? ‘ required’ : ”
    );

    $fields[’email’] = sprintf(
    ‘<label for=”email” class=”screen-reader-text”>%1$s</label><input placeholder=”%1$s%3$s” id=”email” name=”email” type=”email” value=”%2$s” size=”30″%4$s />’,
    esc_html__( ‘Email’, ‘generatepress’ ),
    esc_attr( $commenter[‘comment_author_email’] ),
    $required ? ‘ ‘ : ”,
    $required ? ‘ required’ : ”
    );

    #2532461
    Fernando
    Customer Support

    Does that work? Do you get the Phone number when someone comments? If not, it may be good to use a plugin for this. Example: https://www.wpbeginner.com/plugins/how-to-add-custom-fields-to-comments-form-in-wordpress/

    #2532474
    Srini

    Yes, I have saved phone no using below function

    add_action( ‘comment_post’, ‘save_comment_author_phone’ );
    function save_comment_author_phone( $comment_id ){
    if( isset( $_POST[‘phone’] ) )
    update_comment_meta( $comment_id, ‘phone’, esc_attr( $_POST[‘phone’] ) );
    }
    function print_author_phone( $id ) {
    $val = get_comment_meta( $id, “phone”, true );
    $title = $val ? ‘<strong class=”author_phone”>’ . $val . ‘‘ : ”;
    return $title;
    }

    add_filter(‘manage_edit-comments_columns’, ‘my_add_comments_columns’);

    #2532484
    Fernando
    Customer Support

    This is actually out of our scope of support as it’s more related to WordPress and not the Theme itself.

    However, can you try adding a Snippet like this?:

    add_filter( 'comment_form_fields', 'mo_comment_fields_custom_order' );
    function mo_comment_fields_custom_order( $fields ) {
        $comment_field = $fields['comment'];
        $author_field = $fields['author'];
        $email_field = $fields['email'];
        $url_field = $fields['url'];
        $cookies_field = $fields['cookies'];
    	$phone_field = $fields['phone'];
        unset( $fields['comment'] );
        unset( $fields['author'] );
        unset( $fields['email'] );
        unset( $fields['url'] );
        unset( $fields['cookies'] );
    	unset( $fields['phone'] );
        // the order of fields is the order below, change it as needed:
      
        $fields['comment'] = $comment_field;
        $fields['author'] = $author_field;
    	$fields['phone'] = $phone_field;
        $fields['email'] = $email_field;
        $fields['url'] = $url_field;
        $fields['cookies'] = $cookies_field;
        // done ordering, now return the fields:
        return $fields;
    }

    Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets

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