+ Start a Discussion
John PipkinJohn Pipkin 

Error when creating Customer Portal User

I am trying to create a Customer Portal User through a force.com site with Apex but keep getting the following error:

"That operation is only allowed from within an active site."

I am running the code from the Guest User on the force.com site, the site is active and it's connected to the customer portal, and the account owner has a role. 

Here's the method I'm using:
public static void createPortalUser(String acctId, string email){
    User cu = new User(Username=email,CommunityNickName='test', email=email);
    Site.createPortalUser(cu, acctId, 'test123', true);
What am I missing?
Best Answer chosen by John Pipkin
John PipkinJohn Pipkin
Found the issue. 

The portal profile was included in the Partner Community settings. removed and works great now