You are here

function user_relationship_mailer_form_alter in User Relationships 7

Same name and namespace in other branches
  1. 5 plugins/user_relationship_mailer/user_relationship_mailer.module \user_relationship_mailer_form_alter()
  2. 5.2 plugins/user_relationship_mailer/user_relationship_mailer.module \user_relationship_mailer_form_alter()
  3. 6 user_relationship_mailer/user_relationship_mailer.module \user_relationship_mailer_form_alter()

Implements hook_form_alter().

File

user_relationship_mailer/user_relationship_mailer.module, line 187
Handles email notifications when relationships are added or removed.

Code

function user_relationship_mailer_form_alter(&$form, &$form_state, $form_id) {
  if (($form_id == 'user_register_form' || $form_id == 'user_profile_form') && $form['#user_category'] == 'account') {
    $account = $form_state['user'];
    $access = variable_get('user_relationship_mailer_send_mail', FALSE) && user_relationships_user_access('maintain @relationship relationships', NULL, $account);
    $form['user_relationships_ui_settings']['user_relationship_mailer_send_mail'] = array(
      '#type' => 'checkbox',
      '#title' => t('Receive e-mail notification of relationship activity'),
      '#default_value' => isset($form['#user']->data['user_relationship_mailer_send_mail']) ? $form['#user']->data['user_relationship_mailer_send_mail'] : TRUE,
      '#description' => t("If checked, we will e-mail you when there are changes to your relationship status with other users."),
      '#weight' => -10,
      '#access' => $access,
    );
  }
}