5

I am a Drupal beginner. When users create their account, they have the option to have a personal contact form. Where do I go to disable that? It's not in permissions. It's not a bad option, but I know it will confuse the hell out of my site's users. It may even scare some away!

apaderno
  • 28,547
  • 16
  • 75
  • 90
Behrooz Karjoo
  • 4,250
  • 10
  • 38
  • 48

8 Answers8

6

Tested in Drupal 7.

Place the following in template.php of your theme. Change MYTHEME to your theme name.

function MYTHEME_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'user_profile_form') {
    $form['contact']['#access'] = FALSE;
  }
}

Notice that access is set to false, instead of being unset(), i.e. removed. That way we're not interfering with the flow of data.

Timofey Drozhzhin
  • 4,416
  • 3
  • 28
  • 31
3

If you visit admin/build/contact/settings in Drupal 6 or 5 you can untick "Enable personal contact form by default"

Paul D'Ambra
  • 7,629
  • 3
  • 51
  • 96
2

A personal contact form is not something you get by default in Drupal. There are modules that can do this, you have probably activated such a module. Check what modules you have activated at admin/build/settings.

If you want to disable this for regular users only you should instead check you permission settings.

googletorp
  • 33,075
  • 15
  • 67
  • 82
2

Disable the Contact module under 'Core - Optional'. Look through user permissions for anything related to 'contact' and uncheck it.

Personally recommend Webform to handle site wide contact forms. It will let you construct your form with a UI. Easiest way to get a Contact Us page.

Kevin
  • 13,153
  • 11
  • 60
  • 87
2

Drupal 7

All answers NOT remove the section for personal contact option displayed (D7) at "user/%/edit"

enter image description here

For remove tab AND settings for Drupal 7:

/**
 * Implements hook_form_alter().
 */
function MY_MODULE_form_alter(&$form, &$form_state, $form_id) {
  if ('user_profile_form' === $form_id) {
     $form['contact']['#access'] = FALSE;
  }
}

/**
 * Implements hook_preprocess_page().
 */
function MY_MODULE_preprocess_page(&$variables) {
    $menu_items = menu_get_item();
    if('user/%/edit' === $menu_items['path']){
         $variables['page']['content']['content']['content']['system_main']['contact']['#access'] = FALSE;
    }
}

After:

enter image description here

David DIVERRES
  • 1,811
  • 21
  • 30
  • My answer does remove the section for personal contact option displayed. Check the simplify module. It does exactly what you did here custom in form_alter. – milkovsky Dec 08 '15 at 11:34
1

Drupal 6:

If you want to have the site-wide contact form enabled, but not even display the option for a personal contact form to your users you must follow these steps:

  1. Create a custom module

    http://www.hankpalan.com/blog/drupal/make-custom-drupal-module

  2. Add this code to your .module file:

    function your_module_name_form_user_profile_form_alter(&$form, &$form_state) {

    unset ($form['contact']);

    }

AdamG
  • 2,570
  • 3
  • 24
  • 35
  • I'd advise using $form['contact']['#access'] = FALSE; instead of unset($form['contact']); to prevent it from interfering with the core. – Timofey Drozhzhin Oct 02 '12 at 18:31
0

Either check what modules you have set on drupal, or check the settings for contact forms. I believe it has the option for site wide contact form and user contact form.

Daryl
  • 117
  • 1
  • 7
-1

Use Contact permissions. It provides a permission:

"Have a personal contact form" which allows administrators to configure which roles get the ability to have a "Personal contact form".

Also the Simplify module has a separate option for that.

milkovsky
  • 8,772
  • 4
  • 28
  • 32