You are here:
Extend the Configurable Self-Reg Handler in Apex
When you select the Configurable Self-Reg Page registration type on the Login & Registration page, Salesforce generates the AutoCreatedConfigSelfReg handler. The handler contains logic for users to register with their email address or phone number. You can modify the handler in Apex to customize self-registration. You can add logic to ensure that a new member’s email address and phone number are unique in your org.
You can find the generated Configurable Self-Reg handler from the Setup Apex Classes page. Its name begins with AutoCreatedConfigSelfReg, followed by a series of digits to ensure that the name is unique. You can rename the handler to something more meaningful.
Before you extend the configurable self-reg handler, it's useful to understand how the generated handler works.
If you choose Email as the verification method on the Login & Registration page, when a new user clicks the sign-up link on the login page, Salesforce prompts for an email address. The user receives a one-time password. When the user enters the verification code on the Verify page, their account is created and they're logged in. If you choose Text Message as the verification method, the user is prompted to enter a phone number. Salesforce sends the user a verification code via SMS. When the user enters their code on the Verify page, their account is created and they're logged in. By requiring verification, you can reduce the number of dummy users cluttering your org.
The Auth.ConfigurableSelfRegHandler class contains
logic for generating the user fields required to create a user in case the user doesn’t
supply them. The handler generates default values, ensuring that the values are unique by
appending a timestamp. You can modify the handler to make sure that the email address and
phone number of the customer or partner are also unique.
Now that you understand how the generated handler works, you can modify the code to customize your self-registration process.
-
Find the name of the Configurable Self-Reg handler on the Login & Registration
page.
- From Setup, in the Quick Find box, enter All Sites, then select All Sites.
- Next to your site name, click Workspaces.
- From Experience Workspaces, select Administration, and then select Login & Registration.
- Under Registration Page Configuration, notice the name next to Configurable Self-Reg Handler. For example, AutocreatedConfigSelfReg1535145601649.
-
Find the handler from Setup.
- From Setup, in the Quick Find box, enter Apex, then select Apex Classes.
- To view the code, from the list of Apex classes, locate the handler, and click the name to open it.
-
(Optional) Rename the handler for your convenience.
-
Click Edit.
The name of the Configurable Self-Reg Handler appears in the first line of code:
.global class AutocreatedConfigSelfReg1532475901849 implements Auth.ConfigurableSelfRegHandler -
Replace the autocreated name with your own. For example,
ConfigureSelfRegHandlerMySite. - Save your changes.
-
Click Edit.
- To customize your self-registration process, modify the Apex code. For more information on usage, methods, and example implementations, see the ConfigurableSelfRegHandler Interface documentation in the Apex Reference Guide.

