Any documentation on the CreatePortalUser ? In few cases it does not create community user and do not see any reason why. There is only 1 contact that is passed to it.
system.debug(' test user' +u); system.debug(' test account'+cons.accountid); String userId = Site.createPortalUser(u, cons.accountId, password);
I guess the question is does Salesforce create the contact when it creates the portal user? What I am doing, is setting the contact on the user before I call the method. This works most of the time, SF does not create duplicate contact. However there are certain cases where this fails. Sometime this is due to duplicate contacts even though the specific contact is set on the user record. The other time when there is only 1 contact I do not understand why it fails :(
Also forgot to mention that when this fails I am able to manually create the portal user for the contact. So no clue as to why the self registration failed. I am assigning random number to nickname. Hopefully SF will be nice enough to send me an email.