Self-register for the community in Salesforce

How to set up self-register for the community in Salesforce

Hi, Great to have you here. Today I am gonna show you how to set up self-register for the community with a custom component which allows any fields and validation that you want (see more about custom validation in Lightning in this article)

So let’s say you have already created your community (in case you don’t know how to do it – check out salesforce documentation ) and you are ready to start.

First what you need to do, is prepare a Profile and Account for your community User. So to do it navigate to Setup>Profiles>New and clone it from Partner Community User like below.

Create Community Profile
Create community profile

Then if you didn’t enable “Person Accounts” in your organization, you need to create a default Account for new users or use one of existing, otherwise, skip this step.

Okay, now we can start configuring our self-register for the community, so do it, go to your community and open the “Administration” panel, then go to the tab “Members” and from internal profiles add “System Administrator” and your newly created profile to selected profiles. Click Save.

Add Profiles to members
Add Profiles to members

Still in the “Administration” panel, select the “Login & Registration” tab and scroll to the “Registration Page Configuration”. In this section select “Allow external users to self-register” checkbox, then in “Registration Page Type” select Community Builder Page and in lookup select Register. At the end here fill “Profile” and “Account” fields with these you have created before (If you enabled Person Accounts, then leave “Account” blank). Click Save.

Config self-register for the community

Now when self-register for the community is enabled we have all what is necessary to allow users for self-registration, so open link to your community in an incognito window (to see login page as a logged-out user), notice “Sign Up” button in the bottom right corner, when you click it, you should see something like below:

Self-register for the community
Self-register for the community

So now to test it, provide some data (remember to provide an email that doesn’t already exist in org) to click “Sign Up”. you should get a success message on the screen and email message with a link on your mailbox. Mission Accomplished

We could leave it as it is or add more fields through fieldSet in component attributes, but I want to show you how to use a custom component to completely justify this content.

To do it go to Setup>Lightning Components, select selfRegister aura component and open it in the developer console. What we want to do here is make a copy of this component bundle and name it SelfRegisterCustom (It is not a good practice to modify standard component). After that, we do the same for the apex controller, so open LightningSelfRegisterController class copy it, create z_LightningSelfRegisterControllerCustom, paste code from clipboard and replace all occurrences of “LightningSelfRegisterController” in this class to “z_LightningSelfRegisterControllerCustom”. Now when you have done it, open SelfRegisterCustom and notice a comment on the top of the file which says you need to add “implements=”forceCommunity:availableForAllPageTypes” to your component, so let’s do it and also replace controller to your new apex class, save. After that, the first line of your component should look like below:

<aura:component controller="z_LightningSelfRegisterControllerCustom" implements="forceCommunity:availableForAllPageTypes">

Okay, now go back to your community builder and open Register page, then replace “Self Registration” component with custom component “Custom Self Register”, you shouldn’t notice any difference in the look, but now any change in your custom component will affect to self-register look, you can, for example, use it to set up custom validation for data provided by user.

I hope this article will help you in setting up self-register for the community, Thank you for reading.

Resources: https://help.salesforce.com/articleView?id=networks_setup_maintain_communities.htm&type=5

https://help.salesforce.com/articleView?id=networks_customize_selfreg_page.htm&type=5

https://help.salesforce.com/articleView?id=rss_login_self_register.htm&type=5

5 3 votes
Article Rating
Subscribe
Notify of
guest
8 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Puja Adhikari
Puja Adhikari
2 months ago

Hi,

Helpful article. I did exactly what was described to create custom self register component. But the look is somehow different from the standard one. Standard logo beside the field name is missing and width, height are not matching. Am I missing something here? Could you please advice how to make it exact same like the standard one. Attached the comparison screenshot for reference.
Thanks.

Self Register Component.png
Kiran
Kiran
3 months ago

Enjoyed reading the article above, really explains everything in detail, the article is very interesting and effective. Thank you and good luck with the upcoming articles.

Tigana
Tigana
8 months ago

Hi, I did exactly what was described above to create a custom self register component, its controller and replaced it with the standard Identity self register component on the Register page. On registering as a portal user, I see that the logs are generated for site user and the controller class and its action method of self register is called but execution finishes there. Nothing happens when I click on submit button.. in the logs I cannot see a single debug that I have put on line 1 of the self register method. Can you please advice on what could… Read more »

SFDC
SFDC
1 year ago

Helpful article, i tried following same steps but now that i can see i cannot replace selfRegister component with my custom component, as it is showing it as readonly , Am i missing anything? or we cannot update it with custom component now? Thanks.

trackback

[…] For this tutorial I am using SelfRegister component for Salesforce Community, click here to learn more about […]

Close Menu
8
0
Would love your thoughts, please comment.x
()
x