An ask for a contact form that sends data to pardot turned out to be a fun little plug-in.
Code first;
Plug-in hooks into the ‘wpcf7_submit’ action which occurs after a form is submitted successfully and makes a secondary request to a pardot form handler endpoint.
Config is done in contact form 7 using “additional settings”.
Usage:
- Install this plugin and contact form 7.
- Make a new contact form.
- Make sure the input ‘name’ attributes match your pardot field handles.
- On the forms’ Additional Settings page, add the handler url from pardot.
Example:custom_pardot_form_action_url: "https://example.com/l/999/99-99-99/abcd"
- Save your form.
Note: If WP_DEBUG is enabled; the plug-in will attempt to write to plugins/output.log
This is useful when trying to debug issues with the form handler.
Note: “custom_pardot_form_action_url” must be present for data to be sent to pardot.
Plug-in ignores any forms which don’t have this.
So what was fun about this?
I was aware of another project by the same author called “Flamingo”. It directs the form data to a database. I enjoyed picking that plug-in apart. There were hints there that are not in the ContactForm7 docs. I guess I was surprised there wasn’t something that already did this and amused that it wasn’t that hard to piece together.
Enjoy.