Support » Fixing WordPress » Advice on using contact form 7 hook

  • Hi,
    I have written the following codes:

    // define the wpcf7_mail_sent callback 
    function action_wpcf7_mail_sent( $contact_form ) { 
        $temp1246 = get_post_meta( 1246, $key = 'ID', TRUE);
        $temp1246 = intval($temp1246) + 1;
        update_post_meta( 1246, 'ID', $temp1246 );
    // add the action 
    add_action( 'wpcf7_mail_sent', 'action_wpcf7_mail_sent', 10, 1 ); 

    What the code does is that it will increment a page’s custom value by 1 every time a contact form is submitted. But the problem I have now is that I only want a specific contact form to trigger this code when it is sent, not all the contact forms (I have a few contact forms in the site powered by CF7).

    May I know how can I adjust the codes above so that it is only triggered when the contact form (id = ‘1000’) was sent for example?

    Appreciate if anyone can assist, thank you!


Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Advice on using contact form 7 hook’ is closed to new replies.