Site logo

Archived topic

comment form

10 replies · Started by Srini on February 13, 2023

Viewing posts 1–11 of 11

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.

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?

Hi Fernando,

Please check below video.

Hi Fernando,

Please check below video.

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

Yes, added additional filed

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

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' : ''
);

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');

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

This archived topic is closed to new replies.