Showing gated and ungated content based on form submission - php

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 redirected 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?
Other concerns:
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.
Any ideas?

Related

How to go back without asking to confirm resubmission of the form

I have a web page that loads all the data from a mysql database called datalist.php
From this page I can edit record by record with a button that redirects you to an editdata.php page adapted to the fid of the record.
Once edited as they want to see the changes, I don't redirect them to the main one letting them see the changes and simply clicking back or with a button they return to the datalist.php without any problem.
The button is this
echo "<p id='parrafo'><a style='padding:1px 20px'class='button rounded-0 primary-bg text-white w-0 btn_1 boxed-btn' href='javascript:history.back() '><--</a></p>";
PROBLEM
I added a search engine where the displayed data can be filtered.
When they use the search engine from datalist.php, I direct them to a page called search engine.php where, through a post method, I store what they are looking for in a variable and the data that users want appears.
But when they edit a filtered record, it is edited without problems, but when they go back, they return to the search engine.php and the message appears:
"Confirm form resubmission In order to display correctly, this web page needs the data you entered earlier. You can submit that data again, but that will cause the page to repeat all previous actions. Press Reload to submit the data and display the page.
Hit the page refresh button to resubmit the data needed to load the page."
Of course, if they update, they come back when the filtered data comes out.
Isn't there any way to store the variable used in the search so that when I go back I don't get this error or any solution??
simple! when user will submit form for that variable instead of making post request
option1: just use get request __url__?variable=... but this will not remember the variable when you go back
option2: store the variable in the cookie and just go to next page (eg. window.location.href = '...';). and in next page access the cookie from php.
If you are wanting to show the form to the user as a confirmation, but without the possibility of another post, then remove the form element and the button. Display all other boxes as they are (with the values populated from the POST array).
And display another message telling them that it has been successful.
You are using PHP, you can achieve this easily with it. If you are unsure, then post a short version of your code in a separate question.

How to pass values from lightbox to main page

My main application opens an user page. There are New / Edit / Delete buttons on the same page.
I am using Datatables Editor to display records. When I click on New button an lightbox opens up and the datatables editor build-in plugin shows add user template. When this template is submitted a new record is created. The backend has a AUTO_INCREMENT key which I want to be passed back to main page such that I display a message 'User ID : XXXXX has been created'
The issue is that even though I pass it as a session variable the main page which I believe since it is already loaded and cannot be refreshed after lightbox page is submitted - it never receives the updated session variable. As such session variable though set dynamically when user submits lightbox from backend is never seen in main page
How can I achieve the desired output?

Wordpress send the url the registration form was filled out at as part of the email

I have a wordpress site with two registration forms on it, they are located on two different pages via "theme my login" short code. I would like to be able to track which of the form's the user submitted the registration form on, I'm thinking via the admin email that notify me there is a new user or even as a field as Im using Cimy user extra fields, my question is
1) are either of these options possible
2) which is quicker / easier to achieve as It has to be done asap
3) can you point me in the right direction for guides or even the codex if its that simple.
im guessing the I would need to find the hook in wordpress that is responsible for the admin email and add the wordpress either $_SERVER['REQUEST_URI'] or a wordpress equivilant?
You can include the url of the page which you embed the form, in the email. You can use hidden input field if you have used a custom form. If you have used contact form 7 plugin, you can get needed information from this url http://contactform7.com/special-mail-tags/

PHP rerouting temporarily store the previous output

I have output from a page (Uploader.php). Now i go to some other page and have a button on that page to reroute to this page (Uploader.php). I want the input of the page to be seen rather than reprocessing the page.
From what I can infer of the question you want to have a form that allows the user to upload whatever information. After they submit, you want to either show a 'review' page (for the user to confirm or deny the action to be performed), or a 'results' page to review what was performed/uploaded/input.
For easy of programming I would have two PHP files, Uploader.php and Uploader-View.php
Uploader.php would have your form and post to whatever form action script you have for processing it. The action script could then redirect to Uploader-View.php with the form values placed in the page as text, rather than as form fields.
If you wanted to re-use Uploader.php you could have some variable to determine the state of the workflow and decide whether to show form fields or variable values.

Using Node Data after Node is Created

I'm creating a custom PayPal "Pay Now" button based on the results of the creation of a CCK node. Basically, someone is creating their own "registration" for an event and then are redirected to a "pay now" page which is of the "PHP" input type. When I do a "print_r($_POST)", the variable is empty.
How can I use the data just stored in the new node? Or, at least use PHP to inspect the POST parameters given to create the node? I'm trying to populate a "Pay Now" button for PayPal.
(disclaimer that I have some odd requirements as to how payment is handled/directed, otherwise I would use an existing module like UberCart)
Note that I've turned off users ability to view nodes that they've just created as it contains personal information.
Well, the main question here is how you do the redirection after node submission. After completing a form submit cycle, the user normally gets redirected to whatever ends up in the forms '#redirect' entry. One effect of this redirect is that the POST data will be gone on the target page.
So in order to get access to the created node on the target page, you'll probably have to pass it the nid of the created node, e.g. by adding it to the redirect URL (potential security issue) or storing it in the session data in the node creation forms submit function. Then you can just do a node_load() on the target page, using the passed nid.

Categories