Enable self registration and change homefolder

By Maarten Kling | On Aug 28, 2013
Using python to setup self registration and member type creation, using a normal setuphandlers.py.

I needed to change the member-homefolder from the default Members to my own member folder called 'mymembers' and change the type of the created member object to my own membrane contenttype.

def setupVarious(context):
    mp = getToolByName(getSite(), "portal_membership")
    # set type to custom member type
    mp.setMemberAreaType('mypackage.contenttypes.member')
    # set member folder name
    mp.setMembersFolderById('mymembers')
    
    # call update security 
    set_up_security(context)

Enabling the security settings can be done in the control panel or with some code:

def set_up_security(context):
    """ Enable/disable security controlpanel (a.k.a. @@security-controlpanel)
        settings.
    """

    site = context.getSite()
    
    #site security setup!
    secSchema = ISecuritySchema(site)
    secSchema.set_enable_self_reg(True)
    secSchema.set_enable_user_pwd_choice(True)
    secSchema.set_enable_user_folders(True)

Now we have a website with self registration enabled. When people register, an object of type mypackage.contenttypes.member will be created in mymembers