You are here

function rh_profile2_form_profile2_form_alter in Rabbit Hole 7.2

Implements hook_form_FORM_ID_alter().

This will add Rabbit Hole options to the Profile edit form. The user will be able to override the default Rabbit Hole options.

_state

Parameters

$form:

File

modules/rh_profile2/rh_profile2.module, line 73
Main module file for Rabbit Hole Profile2 module.

Code

function rh_profile2_form_profile2_form_alter(&$form, $form_state) {
  if (!user_access('administer rh_profile2')) {

    // The user doesn't have access.
    return;
  }

  // Load the Rabbit Hole form, and add an extra javascript file that's needed
  // for the fieldset summary.
  foreach (element_children($form) as $key) {
    $element = $form[$key];
    if (isset($element['#entity_type']) && $element['#entity_type'] == 'profile2') {
      rabbit_hole_form($form, 'profile2', $element['#bundle'], 'rh_profile2', $form_state['profiles'][$element['#bundle']]);
      if (isset($form['rabbit_hole'])) {
        $form['#attached']['js'][] = drupal_get_path('module', 'rh_profile2') . '/rh-profile2.js';
        array_unshift($form['#submit'], 'rh_profile2_profile2_form_prepare_submit');
        if (!user_access('bypass rh_profile2')) {
          $form['#submit'][] = 'rh_profile2_profile2_form_submit';
        }
      }
    }
  }
}