hook_menu to change menu button item by checking group membership I am using Organic Groups and I have used this post to override the roles and permissions of OG Groups.

I need a hook to alter a button on my main menu that changes depending on whether the user is a member of a group (has any role in that group) or isn't a member of a group (and therefore hasn't got a role associated with his username)

The default button that always shows is 'add' when a user is associated with a group that button needs to be changed to 'remove' - with the according URL

I have created the following using this Drupal page:

function my_module_menu() {

    $items['link'] = array(
        'title callback' =&gt; 'change_link',
        'title arguments' =&gt; array(1),
        'page callback' =&gt; 'go_to’,
        'page arguments' =&gt; array(1),
        'access callback' =&gt; 'user_is_logged_in',
        'menu_name' =&gt; 'main-menu',
        ); 

    return $items;
}
function change_link($gid) {
  if(og_is_member('node', $gid)) {
    return 'Remove';
  }
  else {
    return 'Add';  
  }
}
function go_to($gid) {
  if(og_is_member('node', $gid)) {
    drupal_goto('www.mydomainurl.com/remove');
  }
  else {
    drupal_goto('www.mydomainurl.com/add');
  }
}


As well as fixing the above code - what does the array(1) do in page and title call back? --> I just copied them as is from the Drupal API page... (Does it look for the 'gid' in the last 2 functions?

UPDATE: (if any user of the site are part of any group - regardless of role -  they will see only the 'remove' button if they aren't part of any group they will see the 'add' button.)
Here is a sample code close enough to your question. It may need some modifications to its parts in order to meet your needs, but more or less you got the idea.

/**
 * Implements hook_menu_alter().
 */
function foo_menu_alter(&amp;$items) {
  $items['alter/%gid/path']['access callback'] = 'og_user_role_callback';
  $items['alter/%gid/path']['access arguments'] = array(1);
}

/**
 * Determine if logged-in user has access to menu or not.
 */
function og_user_role_callback($gid) {

  // Get OG role of the user. Could be 'member', 'non-member' or 'Group administrator'.
  global $user;
  $group_type = 'node';
  $uid = $user-&gt;uid;
  $member = og_get_user_roles($group_type, $gid, $uid, $include = TRUE);

  switch ($member) {
    case 'member':
      return TRUE;
    case 'non-member':
      return FALSE;
    case 'Group administrator':
      return TRUE;
  }
}