Azad Alam
Azad Alam

Reputation: 45

Contact form 7 data to 3rd party REST API service - wordpress

I am trying to send word-press contact form 7 data to a 3rd party CRM using their API. I have tried a plug-in called contact form 7 to API but to no avail. It is not showing me input type name at all. All fields are blank.. image for reference: blank fields showing in dashboard

Please tell me how to correct this or any other way or any reference for same.

Upvotes: 3

Views: 4708

Answers (1)

Akshay Shah
Akshay Shah

Reputation: 3504

Try below code here i assuming that you are having first name and last name as a field and their form name is first-name and last-name respectively.

add_action( 'wpcf7_mail_sent', 'your_wpcf7_mail_sent_function' ); 

function your_wpcf7_mail_sent_function( $contact_form ) {
 $title = $contact_form->title;
 $submission = WPCF7_Submission::get_instance();

 if ( $submission ) {
    $posted_data = $submission->get_posted_data();
 }
 $firstName = $posted_data['first-name'];
 $lastName = $posted_data['last-name'];
}

Upvotes: 2

Related Questions