This tutorial explains how to make a user-registration form. So visitors can register as users at your WordPress-powered website.

Video Tutorial

Written Tutorial

To make any USP Form a user-registration form, follow these two easy steps.

Step 1

First, include the [usp_email], and [usp_name] shortcodes in the form. These are required for registration. Other fields may be added as desired, as explained in step #3. So for now your form content should just have this:

// required fields

[usp_name]  // this will be the registered username
[usp_email] // this will be the user's email address
Note: Feel free to remove the double-slashed comments, like “// required fields”. They are included here for clarity.

Step 2

Next, include the required hidden field in the same form:

<input name="usp-is-register" value="1" type="hidden">

Done! To test that it’s working:

  • Make sure the form is published (make note of the URL where the form is displayed)
  • Log out of WordPress (or use a different browser where you are not logged in)
  • Visit the form as a regular visitor (i.e., not logged in to WordPress)
  • Fill out the form and submit it
  • Log in to WordPress
  • Verify the new user is registered
Note: You can also test user registration on your site by using the “User Registration Demo”, which is included with USP Pro and available on the “USP Forms” screen. Just follow the same steps as above.

Step 3

Now that you’ve got a basic user-registration form like this:

// required fields

[usp_name]  // this will be the registered username
[usp_email] // this will be the user's email address

You may want to add some other user-related fields. Here are some examples:

// optional fields

[usp_url]     // maps to Contact Info ▸ Website
[usp_captcha] // doesn't map anywhere, but is useful for stopping spam

[usp_custom_field form="register" id="1"]
[usp_custom_field form="register" id="2"]
[usp_custom_field form="register" id="3"]
[usp_custom_field form="register" id="4"]
[usp_custom_field form="register" id="5"]
[usp_custom_field form="register" id="6"]

So that’s the URL field, the anti-spam check, and six custom fields. The six custom fields are defined as follows:

// user nicename

name#nicename|for#nicename|label#Nicename|placeholder#Nicename

// user display name

name#displayname|for#displayname|label#Display Name|placeholder#Display Name

// user nickname

name#nickname|for#nickname|label#Nickname|placeholder#Nickname

// user first name

name#firstname|for#firstname|label#First Name|placeholder#First Name

// user last name

name#lastname|for#lastname|label#Last Name|placeholder#Last Name

// user's biographical info

name#description|for#description|label#Description|placeholder#Description

Here we have six custom-field definitions, one for each of the six shortcodes included in the previous form example. These custom fields are configured to collect data for the user’s profile, including First Name, Last Name, Nickname, Description, and so on. Check out the list of registration shortcodes for more details.

Note: when using any USP Form to register users, WordPress automatically handles all of the creating and sending of passwords and other infos via email. So you can add a message to the form that tells users to check their email after registering.

User Roles

When a user registers with any WordPress site, they are assigned a specific role. Which role a user is assigned depends on many factors, including WP settings and things that plugins and your theme may be doing. Assuming a default WordPress installation, here is how roles are assigned when USP Pro is active:

  • If a user registers via USP form, they will be assigned the role specified via the plugin setting, “Default Assigned Role” (USP General tab)
  • If a user registers directly via WP (via the Login/Register screen), then the user will be assigned the role specified via the WordPress setting, “New User Default Role” (WP General settings)

Keep in mind that this applies to a default WP install with only USP Pro active. So if there are other plugins active, their functionality may modify the logic outlined above.

Notes

  1. USP Pro includes a complete, ready-to-go User Registration Form. Check it out in the WP Admin Area under “USP Forms”.
  2. USP Pro includes a plug-n-play Login/Register/Password form that can be added to any Post or Page via simple shortcode.
  3. When registering users, WordPress takes care of all the password-generation and notification emails. You can use USP Hooks to customize some aspects of default notification functionality, such as who receives the notification email, length of WP-generated password, and so on.
  4. If necessary, developers may implement custom passwords for user-registration by overriding default functionality (see the Codex example for redefining the user-notification function). For more info, read the Notice near the top of this post.

Related