How to use HubSpot Forms API in Wordpress pages?
I have to pass dynamic values to the Hubspot Form.
Thanks in advance
How to use HubSpot Forms API in Wordpress pages?
I have to pass dynamic values to the Hubspot Form.
Thanks in advance
The easiest way is to use HubSpot's PHP wrappers to get the data you need: https://github.com/HubSpot/haPiHP
Basically the wrappers are just JSON data fetchers, so you can also just take out the code you need from the wrapper source, if you need to.
Create new HubSpot_Forms instance and use e.g. the get_forms() to get the form data. Each form has an array field embeddedCode, which includes a javascript includer snippet, which outputs the form right where you output the field code. Then just use the JavaScript/JQuery method of your choice to populate the fields with your dynamic data.
If you need to populate fields without JavaScript, you'll have to find out the form field attributes, write your own form code and use the submit_form() method to post the data afterwards.