Skip Navigation

[Resolved] Autoincrement COUNT field, function not working

This support ticket is created 6 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 4 replies, has 2 voices.

Last updated by pamb-2 6 years, 7 months ago.

Assisted by: Christian Cox.

Author
Posts
#629409

I am trying to: auto-increment a field named COUNT in my CPT Issues

I'm using this function:

add_action('cred_save_data', 'increase_custom_value',10,2);
function increase_custom_value($post_id, $form_data)
{
  
    //NOTE: Set your form ID instead of 12
    if ($form_data['id']==2775)
    {
        //Get count field from database and add 1
        $count = intval(get_post_meta( $post_id, 'wpcf-count', TRUE )) +1;
  
        //Update count field
        update_post_meta($post_id, 'wpcf-count', $count);
    }
}

With a CRED form id=2775. I have ajax DISabled.
The field COUNT is numeric.

I just want every new record to get a value in "COUNT" that is the value of COUNT of the last record + 1.

The field keeps getting updated with the same number, "1".

#629697

*post edited* I have disabled all plugins but Toolset:
CRED
Types
Views
MAPS

And the problem still exists.

#630119

I still would like help with this.

#632146

Hi, I'm terribly sorry for the delay in response. This is not normal - for some reason none of the support team members were informed of this ticket until just now. I believe there is a problem in the queue and I have notified my manager of the situation. We will investigate that issue as soon as possible. It looks like another ticket related to this issue was already closed, so please let me know if you need any additional assistance here.

#636648

Thanks for acknowledging that this ticket was not answered. I did get it answered by opening another ticket with the same information.