Wpcf7_mail_sent

A WordPress hook!

wpcf7_mail_sent is a WordPress action hook that is triggered after a Contact Form 7 (CF7) form has been successfully sent. This hook allows you to perform custom actions or modifications after the form submission has been processed and the email has been sent.

The hook is triggered with the following parameters:

You can use this hook to perform various tasks, such as:

  1. Logging the form submission in a custom database table.
  2. Sending a notification to a specific email address or user.
  3. Updating a custom field or meta value in the WordPress database.
  4. Triggering a custom function or script to process the form submission.

Here's an example of how you can use the wpcf7_mail_sent hook:

add_action( 'wpcf7_mail_sent', 'my_custom_action' );
function my_custom_action( $contact_form, $ajax, $sent_data ) {
    // Perform custom action here
    // For example, log the form submission in a custom database table
    $wpdb->insert( 'my_form_submissions', array(
        'form_id' => $contact_form->id,
        'submission_data' => serialize( $sent_data ),
        'submission_date' => current_time( 'mysql' ),
    ) );
}

Note that the wpcf7_mail_sent hook is only triggered if the form submission is successful and the email has been sent. If the form submission fails or is cancelled, this hook will not be triggered.