I'm using Organic Groups (og) and Organic Groups Invite (og_invite) on a D7 site, and see a way to invite a user to the group, but only through the admin panel - enabling the permission for a group member to invite others does not add a link to the group page to send an invite - what am I missing?

2 Answers 2


I have recently used Organic Groups Invite module to add this functionality to a site. It will give you a "OG Invite Button" block that you can place on the user view page.

Edit: Sorry the block wasnt included I had added it with a custom module here is the code:

 * Implements hook_block_info().
function og_invite_button_block_info() {
  $blocks['og_invite_button'] = array(
    // The name that will appear in the block list.
    'info' => t('OG Invite Button'),
    // Default setting.
    'cache' => DRUPAL_NO_CACHE,
  return $blocks;

 * Implements hook_block_view().
 * Prepares the contents of the block.
function og_invite_button_block_view($delta = '') {
  switch ($delta) {
    case 'og_invite_button':
      $block = array(
        'subject' => t('OG Connect Button'),
        'content' => og_invite_button_block_content()
    return $block;

function og_invite_button_block_content() {
  //Get user from profile page
  $user_viewed = arg(1);
  $user_viewed_fields = user_load($user_viewed);

  global $user;
  $output = '';

  $query = db_select('node', 'n')
  ->condition('type', 'group')
  ->condition('uid', $user->uid);

  $result = $query->execute();

  foreach ($result as $row) {

    // Check if the user is already an existing member.
    $exists = db_select('og_membership', 'ogm')
      ->fields('ogm', array('id'))
      ->condition('gid', $row->nid)
      ->condition('etid', $user_viewed)
    if (empty($exists)) {
      $name = $user_viewed_fields->field_name['und']['0']['value'];
      $output .=  '<a class="orange_btn" href="/group/node/' . $row->nid . '/admin/people/invite-users/' . $name . '/' . $user_viewed . '">Invite To Your Group</a>';
  return $output;

Some improvements could definitely be made like theming the link.

You will also want to add the name of the group to the button if the logged in user is the owner of more than one group.

  • Hi pete80 - I don't see the OG Invite Button block listed in the block list after enabling og_invite - is there a separate module to enable the block? Thx
    – user4984
    Jul 23, 2014 at 16:25
  • Ive edited the answer above as the block was not included in the module
    – pete80
    Jul 24, 2014 at 9:53
  • Thanks pete80! I had to modify the queries slightly as I wanted to have the link on the node page for the group, and wanted only the members of the group able to send invitations, but have it working - thanks. (to be clear, the 'OG Link' module does not actually contain code to allow members to send invitations through a link? seems like an oversight...)
    – user4984
    Jul 24, 2014 at 13:32
  • Perfect solution. Worked as expected. Thank you so much!!!!! Jul 26, 2016 at 7:33

I did this in a non-coding way by using a block view instead.

  1. Create a view as a block.
  2. Create a field with Content:NID, Check the "exclude it from display" box.
  3. Create the link by adding another field with Global:Custom text. Unceck the create label box, in the text box add the text you want in the link (ex Invite). Under "rewrite results" check "output this field as a link". Write the link path you want to use with the [nid] token. In my case: group/node/[nid]/admin/people/invite-users
  4. Add filter criteria "Content type = Group".
  5. Change block settings for access to: OG Permission and the permission "unsubscribe from group". This mean that only group members will see the block.
  6. Create a contextual filter Content: Nid. Under "When the filter value is not available", select Provide default value and the type "Content ID from URL". For when the filter value is available I used Specify validation Criteria with validator "content" of content type Group (my group content type) and filter value format Node ID.
  7. Add the block to your Group content type where you want the link to be shown.

I suspect that only one of the contextual filter selections actually is necessary but I am not very good with them and this works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.