Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter LESIMOON

    (@lesimoon)

    Thread Starter LESIMOON

    (@lesimoon)

    I also found some change due to new version, i will add it here just in case someone find this topic.
    To add an action before sending the mail, just do this in your function.php file:

    function cf7_beforesend($cf7)
    {
    $submission = WPCF7_Submission::get_instance();
    
    if ( $submission ) {
    $posted_data = $submission->get_posted_data();
    $email = $submission->get_posted_data('email-1');
    $name = $submission->get_posted_data('nom-1');
    }
    Your_Function_Call($email,$name);
    }

    add_action( 'wpcf7_mail_sent', 'cf7_beforesend' );

    I used your code and added this aswell, so that it would run, but the submit button just keeps spinning and it doesn’t give me any success message. The email is sent though, this happened after an update, anyone that might know the issue?

    Thread Starter LESIMOON

    (@lesimoon)

    Yeah it also happened to me.
    I think it’s because the function is trying to find a data who’s not existing.

    Also, my add_action code is :
    add_action( 'wpcf7_before_send_mail', 'cf7_beforesend' );

    Doesn’t you add_action happened AFTER the mail is sent?

    Hmm, I figured in my case there was something wrong with the php, mysqli_connect() stops the function, probably giving an error, but I don’t know how to catch. It’s just peculiar that it would stop working after an update.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘add action before sending mail’ is closed to new replies.