[Drupal] How to show group field in user registration form by using Organic Group and content type

| | 1 min read

We had a requirement to show the group field in user registration form using Organic groups. Inorder to show group field in user registration form first we have to install the Organic Groups module (OG), Organic groups register module and create an Organic Group.

Lets assume that we have created a group content type named 'User Group'.

Steps to add group field in user registration form

  1. Navigate to Configuration > Organic groups > OG field settings.
    • From the 'bundles' drop down select the created group content type (Here 'User Group').
    • From the 'Fields' drop down select ‘group register’
    • Click 'Add field' at the bottom
  2. Navigate to Configuration > People > Account settings
    • Select 'Manage fields'
    • Edit the field 'Group membership'
    • Select the check-box 'Display on user registration form'
  3. Change the default settings of the group content type created.
    • Navigate to Administration > Structure > Content Types
    • Select the created group content type (User Group)
    • Click 'Manage Fields'
    • Edit the 'Group register' field
    • Change the default value to 'Show on registration page'
  4. Update all groups already created
    • Go to content
    • From the list edit each group that are already created
    • For each group find the 'Group register' and change the option to show it on registration page

Please feel free to share your thoughts and doubts regarding this here.