@francescapenso – sorry it’s not clear from your question what you want to count.
If want to count the number of text characters in a text field, this is now available in CF7 4.1 – see Max & Min Length Options and Character Count.
Hi
i’ll wanto to count the number of email received for every contact form.
I’ve tried to use the method of sevenspark adding in functions.php this code
//Define the key to store in the database
define( ‘CF7_COUNTER’, ‘cf7-counter’ );
//Create the shortcode which will set the value for the DTX field
function cf7dtx_counter($atts){
extract( shortcode_atts( array(
‘counter_id’ => ”,
), $atts ) );
$val = get_option( CF7_COUNTER . $counter_id, 0) + 1; //Increment the current count
return $val;
}
add_shortcode(‘CF7_counter’, ‘cf7dtx_counter’);
//Action performed when the mail is actually sent by CF7
function cf7dtx_increment_mail_counter($atts){
$val = get_option( CF7_COUNTER . $counter_id, 0) + 1; //Increment the current count
update_option(CF7_COUNTER . $counter_id, $val); //Update the settings with the new count
}
add_action(‘wpcf7_mail_sent’, ‘cf7dtx_increment_mail_counter’);
IN the contact form i’ve added
[dynamichidden cf7-counter “CF7_counter counter_id=’5′ “] (id=n nis different for every CF)
and in the mail object
Count: [cf7-counter]
But i’ll receive always count=1
Someone can help me?
I don’t use the “counter_id=”5″” part. I just have [dynamichidden cf7-counter “CF7_counter”] and that works.
mattwarbuckle you use
dynamichidden cf7-counter “CF7_counter”]
also for multiple contact form with different counter?