The problem: You want to register users and allow them to optionally specify if they would like to create a site with their registration as well.
The Gravity Forms User Registration Add-on supports creating a new site by mapping submitted form data to the corresponding site data required to create new WordPress site on a Network-enabled install.
The issue is enabling/disabling site creation is not specifiable by the user submitting the form. If the registration feed has the option enabled, a site is created; if not, a site is not created.
As of version 1.4.3, the User Registration add-on has added support for multiple feeds. This means that we can create multiple registration feeds for the same form and use the “Registration Condition” option to indicate which feed should be used based on the specified user input.
The plan is to create a field on the form that the user can select/deselect to indicate whether they want a site created. We will create two feeds. One to handle registering the user and creating a site and another to only register the user. We will then configure the “Registration Condition” option for each feed so that the correct feed is used by the User Registration add-on dependent on which option the user selected.
- Add “Create a Site?” field to the form
- Create a feed to register user and create site
- Create a feed to only register user
Step 1: Add “Create Site?” field to the form
Go ahead and open up your form for editing. Add a checkbox field and label it whatever you’d like. In my case, I’ve labeled the field “Create a site?”. I then add a single option labeled, “Yes, please create my new site!” Again, the labels here are not significant. Your completed field should look something like this:
Step 2: Create a feed to register user and create site
Our first feed will handle registering the user and creating a new site on the WordPress network. Map the user registration fields as you desire. Be sure to enable the “Create Site” and map these fields as well.
When you get to the “Registration Condition” option, select the field we created in Step 1 from the first drop down, select the “is” option from the second drop down, and select the “Yes, please create my new site!” option (or whatever your affirmative option is) from the third drop down.
Perfect! This feed is now configured to register the user and create a site when the user checks the “Yes, please create my new site!” option!
Step 3: Create a feed to only register user
Our second feed will handle only registering the user and not creating a site. Use the same settings you specified in the first feed and map the user registration fields accordingly. Make sure that the “Create Site” option is disabled.
The “Registration Condition” option will be configured a little differently here. Select the “Create a site?” field we created in Step 1 from the first drop down, select “is not” from the second drop down, and finally, select the “Yes, please create my new site!” option (or whatever your affirmative option is) from the third drop down.
Hot business! This feed is now configured to only register the user (and not create a site) when the user has not checked the “Yes, please create my new site!” option!
This is the easiest way to accomplish optional site creation without touching code; however, if you find yourself wanting/needing to accomplish the same feat from a single registration feed, let us know in the comments and we’ll be happy to share a super simple snippet that can do just that!