Add content type to Drupal Groups drop down menu

Organic Groups is a module that enables you to add group functionality to a Drupal site. You can set any content type to be a group, so that users and content can be associated with it, and also set a content type to be group content, that is be added to a group.

Drupal commons by Acquia is a Drupal distribution with social features, which incorporates the Organic Groups module and functionality through a module named Commons Groups.

We use Drupal as a Video Management System. Recently we wanted to be able to post a video node to a group. We created a video node and marked it as ‘Group Content’ in the Organic Group settings on the content type editing page.

That alone does not make the content type appear on the drop down menu in the group page. For that you need to implement hook_commons_bw_create_all_widget(). Here is an example implementation of the hook:

function MODULE_NAME_commons_bw_create_all_widget($group) {
    if (og_user_access('node', $group->nid, 'create post content')) {
        $link = l('Post a video','node/add/video',
            array('attributes' => array('class' => 'commons-posts-create'), 'query' => array('og_group_ref' => $group->nid))
        return array(
            'MODULE_NAME' => array(
                'default' => TRUE,
                'link' => $link,
                'text' =>  t('Post a video to the group'),
                '#weight' => -1,

When implementing the method in your module, replace MODULE_NAME with your module’s name and replace video with your content type’s machine name. You should also change the link text and comment. Note that clearing the cache might be needed for the added option to appear in the group menu.

When a user clicks the link, he is redirected to the relevant content type node add page, and the group’s id is added to the url as a parameter. With the Entity reference prepopulate module, the group field of the node will be pre populated with the selected group from the query parameter.

Post content to group

Post content to group menu