Drupal - Select organic group on the user registration form

I managed to get this working. These very short instructions are indeed correct. But the first few times I tried to follow them I did not have any success. Therefore I thought it would be useful to explain the steps and potential pitfall in more detail.

I have broken this answer up into two parts. You may have already done the work in Part A of these instructions. I have included them so that if you are really struggling you can go back on a new Drupal installation and ensure that you have followed exactly the same steps as me. You may find this unnecessary, if so skim read Part A and check you are at the right stage before skipping to Part B.

Part A: Steps to install OG and Create an Organic Group (Can be skipped if already completed)

  1. Install Organic Groups and enable it and its submodules (Organic groups register, organic groups UI etc.) as normal (You will need the Entity reference and Views_bulk_operations modules installed to enable these modules). You may need to rebuild the permissions after doing this – you should get a warning if required.
  2. Install Organic groups register which is a submodule of Organic groups - You will need to in order to complete the steps
  3. Create the content type that will be your group (Administration > Structure > Content types). I am calling my example content type ‘Special Group’. Important: in the Organic groups section at the bottom of the create content type select the ‘Group’ checkbox to allow this content type to be a group. Save the content type, you can add the other fields you need once you have everything working.
  4. Create a piece of content using your group content type. (Content > Add Content > Special Group) I called mine My test Group.
  5. In a new browser where you are not signed in, view the new piece of content e.g. ‘My test Group’. You should be able to see the ‘Group: request group membership link’.
  6. Clicking on the request group membership asks you to sign in or register, and then you have to go back to the group to be able to join it. It is this step that we want to improve, by allowing a user to join a group from the registration form.

Part B: Steps to enable group sign up during registration

  1. First we need to add the 'Group register' field to your group content type. To do this go to Configuration > Organic groups > OG field settings.

    1.a. From the Bundles drop down, in the node section, select your group content type (mine is called Special Group).

OG Bundles screenshot

1.b. From the Fields drop down select ‘group register

OG fields screenshot

1.c. Click the ‘Add field’ button at the bottom of the page. After this has been done you should be able to see that the field ‘Group Register’ has been added to the list at the bottom of the page.

OG group register screenshot

  1. Next we need to add field to the user registration form.

    2.a. Go to Configuration > People > Account settings > Manage fields

    2.b. Edit the 'Group membership' field.

    2.c. Select the 'Display on user registration form' checkbox and then save.

Display on user registration form screenshot

2.d. You can now see the ‘Group membership’ field in the Account settings field list with a machine name of ‘og_user_node’ and a field type of Entity Reference.

og user node screenshot

2.e. Warning: Because you have checked ‘Display on user registration form’ there is a temptation to believe that you have completed the task. If you go to register a new account you will be able to see the ‘Group membership’ field, however there will be no groups in the list. Obviously we do want the groups to be listed here. This is where a lot of users were getting stuck. Don’t worry about this. Simply continue to the next step.

  1. Next we need to select which groups appear on the registration page (solving the problem discussed in 2.e.) The default behaviour of the 'Group membership' field that we created in step 2 is set to 'Do not show on registration page' in our group content type that we created in Part A step 2. We need to do two things – change the default so that new groups that are created have the right setting automatically and then update any groups that have already been created.

    3.a. First we will change the default so that new groups that are created have the right setting automatically.

    3.a.i. Go to Administration > Structure > Content Types and edit the group content type you created in Part A step 2 (mine is called Special Group).

    3.a.ii. You can see the Group register field in the list of fields with a Boolean field type (see screenshot 6). Click edit to edit this field.

Group register screenshot

3.a.iii. In ‘Default value’ change the radio button to ‘Show on registration page’ and click save settings. Doing this means that all new groups that are created will be listed in the drop down on the registration page by default

Show on registration page screenshot

3.b. Second we need to update any groups that have already been created.

3.b.i. Go to Content and filter the content by the group content type that you created in Part A step 2 (mine is called Special Group).

Filter by group content type

3.b.ii. You now need to edit each of the groups that have already been created. For each find the ‘Group register’ radio button group and change it to show on registration page.

group register radio screenshot

4.Now you can test that this has worked.

4.a. First we will test our existing groups. In a browser where you are not logged in create a new account. You should be able to see the group that you created in Part A step 3 (mine is called ‘My test group’) in the Group membership list.

group membership list screenshot 1

4.b. Second we will test that new groups that are created have the group register setting correct by default. Create a piece of content using your group content type. (Content > Add Content > Special Group) I called mine My second test Group. You should see that the ‘Group register’ radio button is already set to ‘Show on registration page’ as you are creating the content. In a browser where you are not logged in create a new account. You should be able to see the group that you just created in the Group membership list.

group membership list screenshot2

I have also added these instructions to the Drupal Community Documentation.


At last I found how to do that.

For displaying a group in the registration form, after enable "show on registration form" option in the admin/config/people/accounts/fields/og_user_node page, you should:

  1. Add the group register field to the group fields on the "groups field setting page"
  2. Then you should check the "Show on registration page" option on the group editing page