<?php
//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 cf7dtx1_counter($atts){
extract( shortcode_atts( array(
‘counter_id’ => ‘1’,
), $atts ) );
$val = get_option( CF7_COUNTER . $counter_id, 100) + 1; //Increment the current count
return $val;
}
add_shortcode(‘CF7_counter’, ‘cf7dtx1_counter’);
//Action performed when the mail is actually sent by CF7
function cf7dtx_increment_mail_counter(){
extract( shortcode_atts( array(
‘counter_id’ => ‘1’,
), $atts ) );
$val = get_option( CF7_COUNTER, 100) + 1; //Increment the current count
update_option(CF7_COUNTER, $val); //Update the settings with the new count
}
add_action(‘wpcf7_mail_sent’, ‘cf7dtx_increment_mail_counter’);
?>
I used this code but it doesn’t show correct output.
what is problem????
Any one help me..
Thank you..
I also looking for this solution!
@ramansingh285 did you ever made this work?
mano
(@annaramglobalstf)
I am also looking for this, any help please?
mano
(@annaramglobalstf)
Hi,
I found a solution and its working well by using contact form 7 serial number plugin. No need for any coding.
https://wordpress.org/plugins/contact-form-7-serial-numbers/
Thanks
Manoj