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?