Create Custom Error Messages in the Configurable Self-Reg Handler
If a user makes a mistake when trying to self-register for your site, the Apex handler
displays a generic error message. You can customize the error message that appears on the
self-registration page and verify pages using the Auth.DiscoveryCustomErrorException exception.
Required Editions
Available in: Salesforce Classic and Lightning Experience
Available in: Enterprise, Performance, Unlimited, and
Developer Editions
User Permissions Needed
To access Experience Workspaces:
Access Experience Management OR Manage Experiences OR Create and Set Up
Experiences
AND is a member of the Experience Cloud site
To create and edit Visualforce pages:
Customize Application
To edit Apex classes:
Author Apex
AND Customize Application
If you selected the Email or Text Message verification methods when you configured
self-registration, custom error messages appear on the verify page. If you selected
None for the verification method, the error message appears on the
self-registration page.
From Setup, in the Quick Find box, enter Apex, and then select
Apex Classes.
From the list of Apex classes, find the class that implements Auth.ConfigurableSelfRegHandler.
You can find the name of the handlers on the Login & Registration page of the
Administration workspace. If you haven’t renamed the handler, the name is similar to AutocreatedConfigSelfReg1532475901849
To add the custom error message, edit the Apex class using the Auth.DiscoveryCustomErrorException exception.
For example, throw new
Auth.DiscoveryCustomErrorException('Custom error message defined by the
admin.').
(Optional) Instead of entering the custom error message in the Apex class, you can create
the error message as a custom label.
Custom labels are custom text values that can be translated to the user’s native
language. In this example, CustomError is a custom
label.
throw new
Auth.DiscoveryCustomErrorException(Label.CustomError)
Note You create a custom
error message from the Custom Labels Setup page. The error message can be up to 200
characters.
Did this article solve your issue?
Let us know so we can improve!
Loading
Salesforce Help | Article
Cookie Consent Manager
General Information
Required Cookies
Functional Cookies
Advertising Cookies
General Information
We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required Cookies
Always Active
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional Cookies
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising Cookies
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.