You are here

function role_delegation_form_alter in Role Delegation 7

Same name and namespace in other branches
  1. 5 role_delegation.module \role_delegation_form_alter()

Implements hook_form_alter().

File

./role_delegation.module, line 181
This module allows site administrators to grant some roles the authority to change roles assigned to users, without them needing the 'administer access control' permission.

Code

function role_delegation_form_alter(&$form, $form_state, $form_id) {

  // Only add role delegation options to:
  // * Registration tab of account registration form
  // * Account editing tab of account editing form
  // These are normally the only tabs present on those forms, but other tabs may be added
  // by other modules, e.g. profile editing tabs by Profile 2.
  if (!($form_id == 'user_register_form' && $form['#user_category'] == 'register' || $form_id == 'user_profile_form' && $form['#user_category'] == 'account')) {
    return;
  }
  if (user_access('administer permissions')) {
    return;
  }
  $account = $form['#user'];
  _role_delegation_add_roles_to_form($form, $account);
}