You are here

function hook_domain_nav_options_alter in Domain Access 7.3

Same name and namespace in other branches
  1. 6.2 API.php \hook_domain_nav_options_alter()
  2. 7.2 domain.api.php \hook_domain_nav_options_alter()

Allow modules to alter access to Domain Navigation items.

This drupal_alter hook exposes the $options array before Domain Nav passes its links to the theme layer. You can use it to introduce additional access controls on those links.

Note that "inactive" domains are already filtered before this hook is called, so you would have to explicitly add them again.

Parameters

&$options: The link options, passed by reference, to the theme.

Return value

No return value. Modify $options by reference.

See also

drupal_alter()

theme_domain_nav_default()

1 invocation of hook_domain_nav_options_alter()
domain_nav_render in domain_nav/domain_nav.module
Renders output for the block.

File

./domain.api.php, line 696
API documentation file.

Code

function hook_domain_nav_options_alter(&$options) {
  global $user;
  domain_user_set($user);

  // Remove domains that the user is not a member of.
  if (empty($user->domain_user)) {
    $options = array();
  }
  else {
    foreach ($options as $key => $value) {
      if (!in_array($key, $user->domain_user)) {
        unset($options[$key]);
      }
    }
  }
}