1. In My community AAA is the user. If he wants to create a new user in my community. Is it Possible? If it possible how? Show me the direction

3 Answers 3


Yes community user can create another community user.

Profile pf = [Select id,name from Profile where name ='Volunteer' limit 1];

account acc = [select name from accout where name="individual"];

Contact con = [select id,name,email,lastname,firstname,accoundid from contact where accountid=:accid limit 1];

User u2 = new User(contactId=con.Id, username=con.Email, firstname=con.FirstName,
lastname=con.LastName, email=con.Email,communityNickname = con.LastName + '_' + Rnd,
alias = string.valueof(con.FirstName.substring(0,1) + con.LastName.substring(0,1)), profileid = pf.Id, emailencodingkey='UTF-8',
languagelocalekey='en_US', localesidkey='en_US', timezonesidkey='America/Los_Angeles');

Database.DMLOptions dlo = new Database.DMLOptions();
dlo.EmailHeader.triggerUserEmail= true;
Database.saveresult sr = Database.insert(u2,dlo);

--------------------- Customer Portal User through sites-----------------

account acc = [select name from accout where name="individual"];
User u = new User();
u.Username = Email;
u.FirstName = FirstName;
u.LastName = LastName;
u.Email = Email;
u.CommunityNickname = communityNickname;
String pwdd = Passwd;
system.debug('<< before create user >>');
String userId = Site.createPortalUser(u, acc.id, pwdd); // This method create a customer portal user

Note: Please take care the account you use here who's owner must have role otherwise you will get exception.

  • 2
    It's really good one for me Commented May 12, 2016 at 10:58
  • @ChvlNarayana if this solve your problem. Then you can accept this answer and close this question. Commented May 12, 2016 at 11:05
  • Hi Tushar Sharma It is not working when i create user from debuglog Commented May 12, 2016 at 11:53
  • @ChvlNarayana are you getting any exception. if you are using this method Site.createPortalUser then this method is only supported in community. You can't use this from outside community. Also check account owner must have role. Commented May 12, 2016 at 11:59

Yes, it is. In my community, I create users community with Customer Community Login user license.This link can help you


Yes he can create. just enable "Delegated External User Administrator" option in the profile who do you want to Admin to the Community.

this Option available only few of the licences.

Customer community Puls, Plus login, and a few Other for more information see once https://help.salesforce.com/HTViewHelpDoc?id=networks_DPUA.htm

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .