Setting an automatic membership after user creation

In this recipe, we will show you how to set a default membership for each new created user.

Getting ready

Locate the XML WebUI descriptor for the Organization Service at this path:

<PORTAL_WAR_ROOT>/WEB-INF/conf/organization/organization-configuration.xml

How to do it…

  1. Identify the configuration of the event for the creation of the user:
    <component-plugin>
      <name>new.user.event.listener</name>
      <set-method>addListenerPlugin</set-method>
      <type>
    org.exoplatform.services.organization.impl.NewUserEventListener
      </type>
    ...
  2. Identify, or add if not present, the field membership in the object NewUserConfig$JoinGroup and add the required values for the groupId and the membership as follows:
    <object type=
    "org.exoplatform.services.organization.impl.NewUserConfig$JoinGroup">
     <field name="groupId">
       <string>/platform/users</string></field>
     <field name="membership">
       <string>member</string></field>
    </object>
  3. Save and restart the portal instance.
  4. Create a new user.
  5. Finally, check the membership of the new created user.

How it works…

All the events executed by the creation of the user are captured by the NewUserEventListener. This is done by an extension of the org.exoplatform.services.organization.UserEventListener class. In this configuration, the listener receives the new user according to the rules assigned to the NewUserConfig, in this case groupId and membership.

We can modify these attributes and add the name of a special user that doesn't use the default membership type. Here is an example of this specific case:

<field name="ignoreUser">
   <string>newadmin</string></field>

See also

  • The Adding a custom field in the user profile recipe
  • The Integrating with Web SSO recipe
  • The Integrating with SPNEGO for Desktop SSO recipe
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.36.231