将可下载内容放在wordpress表单后面并生成salesforce领导

I'll try and keep it simple, because there's a lot of moving parts.

  • We have a Wordpress blog
  • We have documents that we want users to be able to download/view (pdfs/etc)
  • We want to generate Salesforce leads off these download/view requests

I've come up with the following pattern:

  • User must submit a form, then receives a link to the downloadable content
  • I'm accomplishing this by utilizing Contact Form 7, Download Monitor, and Email Before Download (all plugins to Wordpress)
  • Email Before Download allows me to utilize Contact Form 7 in collaboration with Download Monitor to expose HTML forms that reveal the downloadable content after the form is submitted (and we get an email with the person's information).

This pattern is close, but what I'd like to do is call into an API to create a lead in Salesforce.

Ideally, what I'd like to do is hook up some custom javascript when the Contact Form 7 form is submitted. I could then use jquery ajax to call into an API to generate the lead. I'm very new to Wordpress and PHP, but have a lot of experience with javascript/jquery, and web development through ASP/MVC... so it's a matter of finding the right place to do this sort of logic in the backend PHP.

Any pointers are much appreciated.

I think the easiest way to achieve this is to hook into the submit function of your contact form. This way, you can just simply send over your data through the Salesforce API.

add_action( 'wpcf7_before_send_mail', 'my_cf7_form_submit' );
function my_cf7_form_submit( $cf7 ) {
    //logic to post to SalesForce API.
}

This will only fire after they've submit the form and right before the wpcf7 plugin sends out the notification emails.

Hopefully this helps.