DEV Community

Cover image for 4 Steps to Create Survey Forms in WordPress that Only Certain People Can Access
WP Meta Box Plugin
WP Meta Box Plugin

Posted on • Originally published at metabox.io

4 Steps to Create Survey Forms in WordPress that Only Certain People Can Access

Want to create a survey, poll, etc. on your WordPress site? Easy peasy! But how can you allow only certain people to access these survey forms, and then hide or remove them after a few days? Sounds difficult, right? But don't worry, we are right here to help you!

First, you just need to create a survey form and then allow the reader to create an account to log in to your WordPress website. Afterward, use a user roles management plugin to limit who can access the survey form. Finally, create an expiration date for the survey / poll. Everything can be done within 4 steps below:

Step 1: Create a Survey Form on Your WordPress Website

There are many ways to create survey forms in WordPress such as using plugins, using custom fields, coding manually, using page builders, etc.

In this article, I use the Gravity Form plugin (premium only). Although there are many free contact form plugins used to create survey forms, polls, etc., I choose this premium plugin because it has many advanced customization options and settings. These advanced settings will be useful in the future when you need more than a simple form.

First, purchase Gravity Form, and then go to Dashboard > Add New > Upload to install and activate the plugin.

Once activating, go to Forms > Add New.

Install and activate the Gravity Form to create survey forms in WordPress

This is the interface to create forms of Gravity Form plugin:

The interface to create forms of Gravity Form plugin

After you finished creating the survey form, insert it to any post / page you want.

If you're using Gutenberg editor, look for the Gravity Forms block and choose the desired form:

Insert the survey form into the page with the Gutenberg editor

If you're using Classic Editor, you will see the button to insert forms like this:

Insert the survey forms with the Classic Editor

Simpler, you can use the following shortcode to display the survey form wherever you want:

[gravityform id="1" title="false" ajax="true" tabindex="49"]

Note: id="1" is the ID of the survey form that you've created.

Step 2: Choose Who Can Access the Survey Form

I'm going to use Member plugin to control who can see and fill in the survey form that we've created in step 1. This is a free plugin that allows you to quickly manage, add user roles and permissions in WordPress.

Upon activation, go to Members > Add New Role. You can grant certain permissions to this user role. However, if you just want to allow them to see and interact with the form, you better choose only the "Read" option in the General section.

Add a new user role that is allowed to access the survey form with Member plugin

Once finishing, go to the survey page, edit it, and drag to the bottom. Here you can choose the user role that is allowed to access and take part in the survey (in this article, it's Form User).

Allow certain people to see and fill in the survey form

Done! You've finished allowing only Form Users to see and respond to the survey.

Step 3: Allow Users to Create Their Accounts

In this step, we are going to allow users to create their accounts on the front end. Once they have their accounts, they will be granted the "Form User" role.

To do that, you need core Meta Box plugin (create custom fields) and MB User Profile extension (create registration and login forms, manage accounts on the front end).

We have an article on how to create an account page on the front end, you can refer to it here.

Once finishing, I went to the front end and took a test. As you can see, when I hadn't logged in yet, I couldn't view the survey. But when I logged in with the account registered as a Form User, I could already see and fill in the survey form.

Users Create Their Accounts and access the survey form

Step 4: Automatically Hide / Remove the Survey Forms

Normally, we just do the survey in a certain term of time. If you want to hide or remove the survey form when the survey ends, you can use Post Expirator plugin (free).

To get more details, refer to this article.

Last Words

This is an easy and straightforward method to create survey forms to collect user feedback and allow certain people to see and participate in the survey. Moreover, you can also automatically hide the survey after it ends. Very convenient, right?

If you're getting stuck with troubles related to meta boxes and custom fields, feel free to share them with us in the comment section or in the Meta Box users group.

Top comments (1)

Collapse
 
kritikgarg profile image
kritikgarg • Edited

πŸ™ŒπŸ’―Thanks, for sharing such Excellent insight! Your step-by-step guide on creating survey forms in WordPress with restricted access is not only informative but also easy to follow. It's an excellent resource for those looking to gather feedback from a specific group of people. πŸ‘πŸ‘

πŸ”Ž Recently, I read an article titled Gravity Forms - Dynamic Forms for Salesforce πŸ“which offers a comprehensive guide to using Gravity Forms in Salesforce. From pricing plans and features to use cases and alternatives, this article is a 🌟 great resource for anyone seeking to use Gravity Forms into Salesforce. πŸ‘