Monday, February 10, 2020

Grab contact form 7 field data during cf7 form submission

Watch out the code below:

add_action( 'wpcf7_before_send_mail', 'm2sys_action_wpcf7_sent' );

function m2sys_action_wpcf7_sent($args)
{
    global $wpdb, $wp;

    $submission = WPCF7_Submission::get_instance();

    if ( $submission ) {
        $posted_data = $submission->get_posted_data();
    }

    $first_name = isset($posted_data['your-name']) ? $posted_data['your-name'] : 'Name not found';   
    $data = 'Your name:' . $first_name;

    update_option( 'cf7_data', $data );
}

No comments:

Post a Comment

Change priority of dual boot OS

Change priority of dual boot OS  (Windows and Linux): Go to your Linux OS, install Grub customizer. Then change priority by up and down arro...