This tutorial explains how to make a user-registration form. So visitors can register as users at your WordPress-powered website.
Video Tutorial
Check out more video tutorials for USP Pro »
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
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
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.
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
- USP Pro includes a complete, ready-to-go User Registration Form. Check it out in the WP Admin Area under “USP Forms”.
- USP Pro includes a plug-n-play Login/Register/Password form that can be added to any Post or Page via simple shortcode.
- 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.
- 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
- Enable Users to Register
- Combo Form: Submit Content and Register User
- Combo Form: Contact Form with User Registration
- Set Values with Hidden Fields
- Override Global Registration Settings
- USP Pro – Login/Register/Password Form
- USP Pro – Password Field
- USP Pro Custom Fields – User Registration Attributes