Loading
Prepare for Email to Become the Default Login ExperienceRead More
Experience Cloud
Customize the Self-Registration Apex Controller

Customize the Self-Registration Apex Controller

For even more control, you can customize how customers and partners register for your site by modifying the default self-registration controller or by replacing it with your own custom controller. You can customize the self-registration controller regardless of which page type you're using.

Required Editions

Available in: both Salesforce Classic (not available in all orgs) and Lightning Experience
Available in: Enterprise, Performance, Unlimited, and Developer Editions
User Permissions Needed
To create an Experience Cloud site: Create and Set Up Experiences AND View Setup and Configuration
To customize or publish an Experience Cloud site:
  • Create and Set Up Experiences AND View Setup and Configuration AND be a member of the site

    OR

  • View Setup and Configuration AND be a member of the site AND have appropriate role-based site access
Note
Note We recommend that you modify the self-registration controller only if you're familiar with Apex. If you're not as comfortable with Apex, but you still want flexibility with your self-registration process, use the Configurable Self-Reg Page and modify its associated handler.

You can generate your own registration form by modifying the CommunitiesSelfRegController and the associated CommunitiesSelfReg Visualforce page. You use this single Apex controller regardless of which registration page type you choose. The customizations you make in CommunitiesSelfRegController override the Login & Registration page settings. In orgs created before the Spring ’15 release, existing Apex customizations for self-registration remain in effect. You also use the CommunitiesSelfRegController controller to implement multiple sites. Then you direct users to the appropriate start URL for each site.

You can add, edit, or delete Apex using the Salesforce user interface only in a Developer Edition organization, a Salesforce Enterprise Edition trial organization, or sandbox organization. In a Salesforce production organization, you can change Apex only by using the Metadata API deploy call, the Salesforce Extensions for Visual Studio Code, or the Ant Migration Tool. The Salesforce Extensions for Visual Studio Code and Ant Migration Tool are free resources provided by Salesforce to support its users and partners, but are not considered part of our Services for purposes of the Salesforce Main Services Agreement.

  1. From Setup, in the Quick Find Box, enter Apex Classes, and then select Apex Classes.
  2. Next to CommunitiesSelfRegController, click Edit.
  3. (Optional) To define which profile to assign to the user, enter a value for the ProfileId.
  4. If you're using a business account, enter the account ID for the partner or customer account that users who self-register are associated with.

    This account ID value overrides the default account set on the Login & Registration page.

    Ensure that the account you use is enabled as a partner. Go to the account, click Manage External Account, then click Enable as Partner.

  5. If you're enabling self-registration for multiple sites, add code to assign the correct profile, role, and account ID to each site.
  6. Save your changes.
  7. Enable access to accounts and contacts for the guest profile. The guest profile is automatically associated with your site.
    1. From Setup, in the Quick Find box, enter All Sites, and then select All Sites.
    2. Next to your site name, click Workspaces.
    3. Select Administration, and then select Pages.
    4. Under Advanced Customizations, click Go to Force.com.
    5. Click Public Access Settings, then click Edit.
    6. Under Standard Object Permissions, next to Accounts, select Read and Create.
    7. Repeat the previous step for Contacts and save your changes.
    8. Under Enabled Apex Class Access, click Edit.
    9. Add CommunitiesSelfRegController to Enabled Apex Classes, and save your changes.
    10. Under Enabled Visualforce Page Access, click Edit.
    11. Add CommunitiesSelfReg to Enabled Visualforce Pages, and save your changes.
  8. Test your self-registration process.

When setup is complete, customers and partner users who submit the completed self-registration form are logged in to the site.

 
Loading
Salesforce Help | Article