Dynamic Contact form 7 counter
-
id like like to create a dynamic counter for each available form,
store it as an array in the db.
how do i get the current form iddefine( 'CF7_COUNTER', 'cf7-counter' ); function cf7dtx_counter($contact_form){ $formid = $contact_form->ID; $formarray = get_option( 'cf7-counter' ); foreach ($formarray as $key => $value){ if ($key == $formid) { $value = $value + 1; }else { update_option( 'cf7-counter', $formarray[$formid][] = $value + 1); } } return $value; } add_shortcode('CF7_counter', 'cf7dtx_counter'); function cf7dtx_increment_mail_counter($contact_form){ $formid = $contact_form->ID; $formarray = get_option( 'cf7-counter' ); foreach ($formarray as $key => $value){ if ($key == $formid) { $value = $value + 1; } else { $formarray[$formid][] = $value; } } return $formarray; } add_action('wpcf7_mail_sent', 'cf7dtx_increment_mail_counter');
- The topic ‘Dynamic Contact form 7 counter’ is closed to new replies.