Showing gated and ungated content based on form submission
I have a HubSpot form embedded into a WordPress page.
What I'm trying to achieve is gated and ungated content. See these use cases as an explanation:
- User enters WordPress page for the first time on content that is gated by default (by gated I mean it shows a form).
- User fills out the form and gets redirected to whatever is specified as the redirect option in HubSpot (the content is now ungated).
- User closes the window but decided to back onto the WordPress page.
- Now, since the user has already filled out the form (the cookie for hubspotutk exists), I want the user to be refirected straight to the asset (whatever is specified in the redirect option in HubSpot forms).
How far have I got?
- I've created an ACF field in WordPress with radio buttons for Gated or ungated content. By default, all content is ungated.
- I've then set a cookie based on this ACF field value. I.e. if the content is gated, resourceType cookie equals "Gated".
- That's how far I have got.
The next steps (I think) would be to...
- Only "ungate" the page if the user has filled out that form. For example, I've completed a form, the hubspotutk cookie value is "23a43a4a6de9c38f7657ebd08d574scf". How does HubSpot know which form this value is assigned to?
- If the user has filled out the form already, how to I redirect them straight to the asset? Is there a way to get the "redirect to another page" value in the image below as a variable?
I don't want to use HubSpot Forms API because I don't expect the admin to create the forms via the API. They'll want to create it via the HubSpot forms option.