Using our Web Apps feature, you can easily allow customers to add their own dynamic Web App items. By default, however, customers are required to be logged in to a secure zone in order to submit their items.
With a little help from the handy jQuery framework, we can bypass this requirement - allowing visitors to anonymously submit new Web App items without the need for logging in to a secure zone.
Note: This guide assumes that you've already built a Web App with customer submitted items enabled - ready for inserting on a page. Find out more here.
Step 1. Create an anonymous user
To set this up, we'll need to create a "dummy" account that will be used each time a customer submits a new item.
Simply click Customers > Create new contact and create the customer, making sure to fill out the "Username" and "Password" fields.
For this example, we only need to enter in 3 fields - first up, we'll enter "Web App Submissions" as their first name.
Then enter "Anonymous" in the Username field, and "User" as the Password.
Click "Save & Finish" to save the contact details.
Step 2. Insert the Web App input form on your page
The next step is to insert our Web App input form on a page.
We'll create a new page and then navigate to Module Manager > Web Apps, and select "Web App Input Form for Customers".
Select the Web App you've set up to accept customer submitted items and then click "Insert" to see the form inserted on the page.
Next up, we need to include the jQuery code on our page.
Switch over to HTML mode, then insert the following code inside the HEAD of your page:
Note: In this sample code, we're referencing a version of jQuery hosted on the jQuery site. If you are hosting the jQuery .js library on your site, simply change the src= tag to reference your own copy of the file.
Note2: You will want to use this example in conjuction with your form. If you have a web submission on a page you can log the person in as they load the page or you can do so during the .submit() process.
Make sure to replace "Anonymous" and "User" with the username and password we assigned our "dummy" customer record earlier.
This script uses jQuery to automatically log the visitor in using your anonymous username and password upon page load. When they go to submit the Web App item submission form, they'll already be logged in to the anonymous account behind the scenes -meaning the form will submit successfully and they'll be taken to the confirmation / approval page.
If you have approval rules set up, you'll still receive notifications as per usual and be required to approve the new Web App item before it is visible on the front-end of the site.
Finally, save and publish the page.