Hi

Is it possible to stop people enabling their own personal contact form? I only need a site-wide contact form, and maybe a couple of personal contact forms (specified by administrators), but I don’t want every user to have one. Does anyone know if this is possible?

Many thanks

Comments

agrathea’s picture

I was looking for this as well, and found this post:

http://drupal.org/node/138574#comment-279828

At the bottom is a module to install so that you can control this better through role permissions. I hope it helps!

agrathea

agrathea’s picture

Ack, sorry, this is for 6.x Drupal... Doesn't help me unfortunately! I'm guessing you're looking for 5, too?

agrathea

agrathea’s picture

After a little more digging, it seems that there are two options:

Keep the contact form module and just make it so that the site wide contact form is disabled automatically (but the user can still select if they like... which I am guessing you don't want to do).

Or if you only need a couple of forms, use the "Webform" module and make specific forms that just go to those select individuals. I just did it and it worked quite nicely, though there are some odd things if you have TinyMCE enabled (you will basically need to turn off rich text format for some of the options).

I liked the Webform better because I had more control over the functionality of the form, and viola, no more worries about the contact forms being available for all users!

agrathea

aangel’s picture

My site-wide contact form was already built and I just needed to turn of the ability for users to turn on their personal contact form.

I didn't try the module above, but borrowing its technique, I added the code below, which did the job nicely.

// Turn off ability to turn on contact form
function mymodulename_form_alter($form_id, &$form) {
  if (arg(0)=='user' && arg(2)=='edit') unset ($form['contact']);
}

If you don't already have a module for glue code like the above, you'll need to make one first.

Don't forget to turn off the actual contact form itself:

// Prevent access to the contact tab as well
function mymodulename_menu($may_cache){
  $items = array();
  if (arg(0)=='user'){
    $items[] = array('path' => 'user/'. arg(1) .'/contact',
      'access' => FALSE,
      'weight' => 2,
    );
  }
  return $items;
}

Don't forget that the admin user will ignore the code above (uid=1).

Andre'

clau_bolson’s picture

Please André, where did you add this code?

goodeit’s picture

Someone posted this as a module a while ago, which works well for me:
http://drupal.org/node/138574#comment-545432

sumaiyajaved’s picture

The above custom module code was not working for me. The following worked:

function mymodule_form_alter(&$form, &$form_state, $form_id) {
//disable private contact form
if (arg(0)=='user' && arg(2)=='edit') unset ($form['contact']);
}

Regards,

Sumaiya Javed
Web Developer
www.sumaiyajaved.com
www.phpjavascript.com