You might find that you have a reason to hide a form on your storefront from customers who haven't registered or logged-in. If you have a secondary form that you are using to collect additional data from your registered customers (not to be confused with an edit account form), it would be understandably be important to make this form only available to your registered customers. This article shows some quick tips and tricks for how to accomplish this.
How to hide a form from guest users
1) Add a form step
Add a step to your form and name it "Login Details" or something similar. This step should contain some display elements such as a paragraph and a heading that instruct guests to login or register before gaining access to the form. It might be a good idea to provide a link to your store's login and/or registration page to make it easier for guests. See the screenshot below for an example:
2) Create a form rule
Create a form rule that uses the Customer is not logged in condition, and then add the following actions:
Hide step [select your form step/s]. This will hide the form's input fields from guest users.
Show step [select the "Login Details" step]. This will show the "Login Details" step for guest users.
Hide form actions and errors. This will hide the form's buttons, making sure that only the content of "Login Details" step is shown to guest users.
See the screenshot below for an example of what this rule might look like:
And there you have it! Once your extra step and form rule are in place, your form should effectively be available to only logged-in users. If a guest on your store (who isn't logged in) happens to stumble across the page that contains your form, they might see something like this:
Prompt user to log in
What if you need to just advise existing customers to login if they already have an account, prior to submitting the form? If you need existing customers to be able to submit the form, it's helpful to be able to let them know that they should login first. This can be accomplished easily with a display elements and a special URL:
1) Add a display link element
Using one of the app's display elements (the link field), you can provide a link to the customer to prompt them to login if they already have an account. You can even add a display header element to make it unique to your form:
2) Edit the link to contain a return URL
Now that you've added your link element, you can add a special return URL to ensure that customers are redirected back to your form after they've logged in. See below for an example of what this might look like:
Note: you will have to change
/pages/test-form to use the local URL for the page that your form is installed on.
Questions, comments, or concerns?
Feel free to reach out to our support team via email or chat and we'll be happy to assist!