The User Forms facilitate the creation of new WordPress users using CRED forms. CRED can automatically generate usernames and passwords for new users. While CRED auto-generates the login details for new users, you will need to set up a notification email that will deliver these login details to the newly created user. Without the notification email, the user will exist in the WordPress dashboard, but will be unable to log into his/her WordPress account.
CRED plugin version 1.4 introduces the CRED User Forms feature, which facilitates the creation of users via front-end forms. One of the important features of CRED User Forms is the automatic generation of usernames, nicknames, and passwords.
When auto-generation is used, especially to generate passwords, the newly registered users need a way to retrieve their auto-generated login information. This is where the CRED User Forms Notification feature comes in.
When editing your form, you can click on the Auto-Generate User Form button in the Form Content section for CRED to automatically generate the form content. In the dialog box that pops up, there are three checkboxes to enable auto-generation of login information, as shown in the following image.
When auto-generation of the user login information is enabled, we need to make sure that the new user receives his/her login information via email. Therefore, we need to click on the Add another notification button in the Notification Settings section, which will display all the available options for the newly created notification.
First, we need to configure the time and the recipient of the notification email:
- When to send this notification – we will want to use the first default option labeled The new user created .
- Where to send this notification – this has to be set to the second option, Send notification to an email specified in a form field and the second drop-down menu of this option should be set to the user_email field option.
Next image demonstrates the correct configuration method of the above-mentioned options.
Now, we need to insert the actual login information fields into our email notification. As with any email, we will need to provide the subject and body content for the notification email. Usually, the actual auto-generated login information fields are present in the email body.
To insert user information fields into email notifications, we can either use the Fields and Views or the Insert Subject Codes and Insert Body Codes buttons, respectively. Both will produce the same output in the notifications and the main difference is in the way user information will be inserted.
When we use the Insert Subject Codes or the Insert Body Codes buttons, user fields will be inserted in the form like this:
%%FIELD_NAME%%. So, if we insert a user ID field, it will be inserted like this:
Following image shows the empty Notification mail subject and Notification mail body fields as well as the dialog box that pops-up when we click on the Insert Subject Codes and Insert Body Codes buttons.
The following image shows an example of a simple notification email:
Using the Fields and Views button, we can also insert custom User Fields, in the form of a shortcode. So, if we insert a custom date User Field, it will be inserted like this:
[types usermeta="date-of-birth" style="text" format="F j, Y" user_is_author="true"][/types]
This shortcode will output the “Date Of Birth” field value, but we have to manually set which user this will apply to. In this case when we want to output this User Field for the user being created by the form itself, we need to add user_id=”%%USER_USERID%%” argument to the shortcode, like this:
[types usermeta="date-of-birth" style="text" format="F j, Y" user_id="%%USER_USERID%%" user_is_author="true"][/types]
You can also add custom fields to your notifications by using the Fields and Views button, as explained in the following table.
|1. Click on the Fields and Views button||2. Choose the field to insert||3. The shortcode for the field is inserted to the Mail Body|
To make sure the final appearance of the email notification is based on your preference and holds all the important information, you can send a test notification.
To do this, click on the Send a test email button present at the bottom of the notification options. In the dialog box that pops up, enter an email address and click on the Send now button.
Please note that the test email won’t contain the actual login information but will only display placeholder names. Next image shows an example of the received test email.
Finally, let’s take a look at how the same sample email notification looks like after an actual user is created using front-end forms.