It seems that in some cases, not all sites that use the contact form will want to give all their users the ability to provide a personal contact form. The attached patch adds a new permission to the contact module that allows site admin to dictate which roles can have personal contact forms.

Comments

unghander’s picture

Category: feature » support

This is exactly what I need but can anyone please tell me how to install that patch? Must I copy the file in the contact folder or in the permissions folder or where?

Gurpartap Singh’s picture

Version: 5.x-dev » 6.x-dev
Category: support » feature

Read about patches: http://drupal.org/patch
Applying patches: http://drupal.org/patch/apply

dokumori’s picture

StatusFileSize
new623 bytes

Here's a module for 5.x that does the same thing (pretty much). Using this module allows easier maintenance than applying a patch.

darumaki’s picture

Version: 6.x-dev » 5.5

I tried your mod for 5.x but it doesn't show up in the mod list

matt b’s picture

This module has been on my 5.x site for some time and works great. I'm thinking of upgrading to 6.x - any chance of a 6.x version of this module?

matt b’s picture

Version: 5.5 » 6.3
StatusFileSize
new693 bytes

I've upgraded this to work on drupal 6. Tarball attached.

mjourney2’s picture

The 6.x module does not seem to be working for me. I uploaded the files in the modules dir and enabled the module. Then I selected the roles who should have x_contact access. But the form still appears on everyone's profile. What am I missing? Thanks.

darumaki’s picture

It worked for me, try rebuilding permissions

rsantiag’s picture

Great!! that works!!!

pasqualle’s picture

Version: 6.3 » 7.x-dev
Assigned: ultimike » Unassigned
Status: Active » Needs work
Rob T’s picture

Matt's #6 worked as advertised in my 6.6 install. Thanks!

I ended up using x_contact_option to create a similar module - x_picture_option - that can restrict specified roles from accessing the upload picture form in profile.

If any of these bust, I'll be sure to chime back in.

wrb123’s picture

Thank you so much, Matt B, for the D6 module! I have a site that is live and I was forced to hide that part of User Profile / Edit with CSS (*shudder*). I extracted the tar to my /sites/all/modules/, enabled it under modules, and then gave only administrators the permission.

Awesome!

-Bill

matt b’s picture

Bill - you're welcome, but I think that the real thanks go to dokumori (#3) who provided the 5.x module in the first place!

This just shows that this permission should be in drupal core.

karens’s picture

There may be overlap with #371621: Create permission to use personal contact form, #386572: Giving permission to contact any user, #58224: Allow anonymous users access to a members personal contact form. #58224: Allow anonymous users access to a members personal contact form seems to be the current issue for changes in the permissions for the contact form. Maybe this issue could or should be rolled into that one?

karens’s picture

Status: Needs work » Closed (duplicate)

In fact, I'll mark it a duplicate. Someone can re-open if there is some reason why this can't be merged into that issue.

k3vin’s picture

+1

crutch’s picture

yay, this is much better than my hack I was using. Thanks so much.

The only reason I hacked in the first place is that when a user clicks on the link in the help text under the check box it shows access denied. From a usability standpoint a user thinks this is an error and they think the personal contact form is not functional when in fact it works just fine. There is no way to explain it every time to every user to make them understand.

WildKitten’s picture

Worked perfect for me in drupal 6. Ty m8 :)

Weka’s picture

Thank you Matt and documori. This is a must have module.
Is there a reason that this module is not included in the Modules section?

massimoi’s picture

I've just made a little modification to #6 in order to get the right form, even if the url is different.

/**
* implementation of hook_form_alter
* hide personal contact form for all users
*/
function myarea_option_form_alter(&$form, $form_state, $form_id)
{
if ($form_id=='user_profile_form'){
unset ($form['contact']);
}
}

Regards,
Massimo
----------------------------
http://impronta48.it

massimoi’s picture

Version: 7.x-dev » 6.9

I've just made a little modification to #6 in order to get the right form, even if the url is different.

/**
* implementation of hook_form_alter
* hide personal contact form for all users
*/
function myarea_option_form_alter(&$form, $form_state, $form_id)
{
if ($form_id=='user_profile_form'){
unset ($form['contact']);
}
}

Regards,
Massimo
----------------------------
http://impronta48.it

sol1313’s picture

Worked like a charm! Many thanks!

mylesorme’s picture

Agh, shame, the module has not worked for me in 6.14 - I still have all the user contact forms.

I've tried setting ever role to having permission; then turning it off for every role, rebuilding permissions table each time - no joy. boo hoo.

Any suggestions anyone?

Thanks

3dloco’s picture

3dloco’s picture

Installed #6 on 6.14 and it is working for me! Thank you!

xaviercas’s picture

Installed #6 on 6.15, working great, thank you very much.

skelly’s picture

Version: 6.9 » 7.x-dev
Status: Closed (duplicate) » Active

@#15 KarenS

At your suggestion I have re-opened this as it has not been addressed by those issues and they are now closed.

I use this incredibly simple, straightforward and seemingly safe core patch on just about every site I create and have applied it to 4.7, 5, and 6 sites.

It would seem to me a pity not to at least get it added to D7.

I'm busy but happy to try to make that happen with guidance.

dave reid’s picture

Status: Active » Closed (duplicate)

We've had more progress so far in #254460: Add permission to *have* a personal contact form but at this point its too late to get into D7.

gillypots’s picture

Excellent, many thanks , worked a treat !!

sadist’s picture

Thank you so much!!

dkane’s picture

#6 is spectacular. Thanks so much!

john.kenney’s picture

#6 works for me on 6.15.

nice job. thank you.

dc1258’s picture

Number 6 does not work for me. When a user selects another user profile two things happen:

-If they are friends, the contact tab is not shown.
-If they are not friends the contact tab is shown.

Any idea what's causing this problem?

john morahan’s picture

The reason #6 doesn't work is because in D6, hook_menu is called once, when the menu is being rebuilt, and whatever the arg() and user_access() functions happen to return at that time will get stuck in the menu definition forever (or at least until the menu is rebuilt again). Also, 'access' doesn't exist anymore.

Instead, you need to implement hook_menu_alter and fiddle with the access callback. Something like this perhaps (untested):

function x_contact_option_menu_alter(&$items) {
  $items['user/%user/contact']['access callback'] = 'x_contact_option_tab_access';
}

function x_contact_option_tab_access($account) {
  return user_access('create personal contact form', $account) && _contact_user_tab_access($account);
}
dc1258’s picture

Unfortunately I am really not good at code development and would have no idea to implement this. If someone else knew how to do this and confirm it works that would be great!

vireodesign’s picture

subscribing

skizzo’s picture

Subscribing. Applied #6 to D6.18 and rebuilt access permissions. Contact settings is now correctly removed from Profile edit page but
Contact tab is still appearing in user page, and contact form can still be used. If anyone has applied suggestion #34 please share the updated patch. Thank you.

sadist’s picture

Skizzo. Did you logged in as a normal user or user-1? Superadmin (user-1) will still be able to use the contact form.

skizzo’s picture

I logged in as a normal user, but your response prompted me to do some more testing and I realized that one user had its "allow contact" flag turned on before enabling x_contact_option, and I happened to do my testing against that specific user... So, you could disable personal contact site-wide, and still enable it for some users (controlled only by admin). Thank you!

mr.j’s picture

Patch at #6 plus #34 works for D6 but a contact form for user 1 always shows up as the admin has all permissions.

But we don't want any user contact forms at all.
To remove it completely for all users you just need to put code like this in your own module:

function yourmodule_menu_alter(&$items) {
  unset($items['user/%user/contact']);
}
freelylw’s picture

subscribing

rplescia’s picture

This all works fine except that when users register the 'contact' option is set to true by default so it means you can still see the tab unless the user unticks the box or the "contact";i:1; value is changed to "contact";i:0; in the data filed of the users table. Is there a way to change the default register behaviour so that this can be set to false.

rplescia’s picture

Nevermind, answered my own question. Just go to Admin >> Contact >> Settings and uncheck the box at the bottom of the page.

deminy’s picture

A D7 version (module 'no_contact_option') can be found from here http://drupal.org/sandbox/deminy/1213640 . Please note that there is a new permission "Use users' personal contact forms" introduced in D7 core, so this module doesn't need to add any new permission in D7.

In D7, module 'no_contact_option' does one thing only: remove option 'Contact settings' completely from user edit page.

For any issues, please report it under the sandbox project. Thanks