Title: Code not working, please help
Last modified: December 11, 2020

---

# Code not working, please help

 *  Resolved [facabo](https://wordpress.org/support/users/facabo/)
 * (@facabo)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/code-not-working-please-help-2/)
 * Hi,
 * I am trying to add a consucutive number that is automatically updated for every
   new form in wpforms, they have a sample to do it in a single form, trying to 
   do it for 2 differenet forms, but i think my code is not right, can anyone help
   me to code it right?
 * Thanks in advance
 * /**
    * Increment total entry number on each submission * * [@link](https://wordpress.org/support/users/link/)
   [https://wpforms.com/developers/how-to-increment-a-count-on-each-form-submission](https://wpforms.com/developers/how-to-increment-a-count-on-each-form-submission)**/
   function wpf_dev_update_total_field( $fields, $entry, $form_data ) {
 *  // Only run on my form with ID = 26555
    if( $form_data[ ‘id’ ] != 26555 ) { 
   return $fields; // Count the entries so far and increment the hidden field count
   by 1 on each submit $fields[108][‘value’] = wpforms()->entry->get_entries( array(‘
   form_id’ => 26555 ), true ) + 1; return $fields; }
 *  // Only run on my form with ID = 26596
    if( $form_data[ ‘id’ ] != 26596 ) { 
   return $fields; // Count the entries so far and increment the hidden field count
   by 1 on each submit $fields[107][‘value’] = wpforms()->entry->get_entries( array(‘
   form_id’ => 26596 ), true ) + 1; return $fields; }
 *  return $fields;
    } add_filter( ‘wpforms_process_filter’, ‘wpf_dev_update_total_field’,
   10, 3 );

Viewing 1 replies (of 1 total)

 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/code-not-working-please-help-2/#post-14165906)
 * It looks like you’ve tried to combine two of the same snippet and it hasn’t really
   worked.
 * Here’s a fixed-up version of your code:
 *     ```
       /**
        * Increment total entry number on each submission
        *
        * @link https://wpforms.com/developers/how-to-increment-a-count-on-each-form-submission
        *
        */
       add_filter( 'wpforms_process_filter', function ( $fields, $entry, $form_data ) {
   
       	// Only run on my form with ID = 26555 or 26596
       	$form_ids = array( 26555, 26596 );
   
       	if ( ! in_array( $form_data['id'], $form_ids ) ) {
       		return $fields;
       	}
   
       	// Count the entries so far and increment the hidden field count by 1 on each submit
       	$fields[4]['value'] = wpforms()->entry->get_entries( array( 'form_id' => $form_data['id'] ), true ) + 1;
   
       	return $fields;
       }, 10, 3 );
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Code not working, please help’ is closed to new replies.

 * ![](https://ps.w.org/code-snippets/assets/icon.svg?rev=2148878)
 * [Code Snippets](https://wordpress.org/plugins/code-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/code-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-snippets/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * Last activity: [5 years, 3 months ago](https://wordpress.org/support/topic/code-not-working-please-help-2/#post-14165906)
 * Status: resolved