• Resolved ivansa

    (@ivansa)


    I have two diferents form, each one with a counter.
    The counters adds +1 number everytime any form is sent with a function add_action(‘wpcf7_mail_sent’…..

    The problem is both counters increaces by 1 on any form sent.
    I created a function in order each form triggers a different counter adds like this. But it’s not working.

    add_action( ‘wpcf7_mail_sent’, ‘your_wpcf7_mail_sent_function’ );
    function your_wpcf7_mail_sent_function( $contact_form ) {
    $title = $contact_form->title;

    if ( ‘Application Form’ == $title ) {

    add_action(‘wpcf7_mail_sent’, ‘cf7dtx_increment_mail_counter2’);

    } elseif

    ( ‘TALK_ES’ == $title )

    {
    add_action(‘wpcf7_mail_sent’, ‘cf7dtx_increment_mail_counter’);

    } //endif
    }

    Both funcions cf7dtx_increment_mail_counter and cf7dtx_increment_mail_counter2 works fine if triggered alone with add_action(‘wpcf7_mail_sent’, ‘cf7dtx_increment_mail_counter2’);
    But they don’t work inside the code above

    Thanks for your help.

    https://wordpress.org/plugins/contact-form-7/

Viewing 1 replies (of 1 total)
  • Thread Starter ivansa

    (@ivansa)

    My fault!

    Should have called the action
    cf7dtx_increment_mail_counter();
    instead
    add_action(‘wpcf7_mail_sent’, ‘cf7dtx_increment_mail_counter’);

Viewing 1 replies (of 1 total)

The topic ‘different "on email sent" function per according form’ is closed to new replies.