Same name and namespace in other branches
  1. 4.6.x modules/contact.module \contact_user()
  2. 4.7.x modules/contact.module \contact_user()
  3. 5.x modules/contact/contact.module \contact_user()

Implementation of hook_user().

Allows the user the option of enabling/disabling his personal contact form.

File

modules/contact/contact.module, line 160
Enables the use of personal and site-wide contact forms.

Code

function contact_user($type, &$edit, &$user, $category = NULL) {
  if ($type == 'form' && $category == 'account') {
    $form['contact'] = array(
      '#type' => 'fieldset',
      '#title' => t('Contact settings'),
      '#weight' => 5,
      '#collapsible' => TRUE,
    );
    $form['contact']['contact'] = array(
      '#type' => 'checkbox',
      '#title' => t('Personal contact form'),
      '#default_value' => !empty($edit['contact']) ? $edit['contact'] : FALSE,
      '#description' => t('Allow other users to contact you by e-mail via <a href="@url">your personal contact form</a>. Note that while your e-mail address is not made public to other members of the community, privileged users such as site administrators are able to contact you even if you choose not to enable this feature.', array(
        '@url' => url("user/{$user->uid}/contact"),
      )),
    );
    return $form;
  }
  elseif ($type == 'validate') {
    return array(
      'contact' => isset($edit['contact']) ? $edit['contact'] : FALSE,
    );
  }
  elseif ($type == 'insert') {
    $edit['contact'] = variable_get('contact_default_status', 1);
  }
}