This is a follow-up to the spam issue. Since I now have suspect users with authenticated accounts, I'd like to disable the ability for users to contact each other via personal contact forms.
Turning off the checkbox on the admin UI, however, doesn't disable the contact form for pre-existing users who already have this enabled.
Searching around, I discovered that whether or not to enable the user contact forms is stored in the user "data" field, a serialized array (aka: long text string)
a:9:{s:13:"form_build_id";s:37:"form-9b87d749e9e89a03db1eb184f1c323aa";s:7:"contact";i:1;s:14:"picture_delete";i:0;s:14:"picture_upload";s:0:"";s:5:"block";a:1:{s:5:"block";a:1:{i:13;i:1;}}s:8:"new_role";i:0;s:12:"new_role_add";s:1:"5";s:16:"new_role_add_qty";s:0:"";s:24:"new_role_add_granularity";s:3:"day";}
Playing around, it looks like I could just go into the database and change "contact";i:1 to "contact";i:0 and all would be well. But I noticed that when I changed it via the User Edit page, the form guid in the above also changed. Anyone know what that's about?
Would hacking the DB to change "contact";i:1 to "contact";i:0 be a really, really dumb thing to do?
Anyone have experience with this?
Thanks!
Syne
Comments
Disable the module?
How about just disabling the Contact module? Unless you are also using it for a site-wide contact form, that should be fine.
And if you are using it for a site-wide contact form, you can install Webform and get a much better contact form module anyway (e.g. allows defining multiple forms, you can add fields to the form, saves the responses so you can export them, etc.). http://drupal.org/project/webform
Drupal programmer - http://poplarware.com
Drupal author - http://shop.oreilly.com/product/0636920034612.do
Drupal contributor - https://www.drupal.org/u/jhodgdon
That'll Work!
I do need a site-wide contact form, so just read up on and watched screencasts on Webforms. It looks great! It also looks like it might a better solution to doing quick little user polls than the built-in Poll module.
Thanks for the tip!
or CCK
Hi WeaveGeek-
You can also make a nice contact form using CCK - just make a content type for it eg. "contact", allow anonymous users to create content of that type, and set the default for the content type to unpublished so that they aren't posted publicly on the site. This works best if you are using Mollom to block spam.
If you want to get fancy, you can set up a view for admins to see all contact content submitted, and if you add Rules module, you can set it up so that an admin gets an email notification when new content is submitted.
Might be nicer for maintenance purposes than webform.
Thanks for the idea!
Thanks for the additional option. I'll give that a look/think.
But back to my original question. How crazy is it to hack the users.data field in the database? I've found workarounds (that sound even better than what I had) but it does kinda bug me that if you accidentally set a checkbox wrong for a given time, you pretty much have to abandon the Contact module.
P.S. I'm bummed to miss tonight's meeting, but I had to be a mum tonight. (And my 6yo son isn't quite ready for Drupal development...yet.)
The youngest core contributor
The youngest core contributor is/was 12, so you better get him started soon!
I disabled user contact forms
I disabled user contact forms by looking up this code in contact.module (line 162):
<?phpfunction contact_user($type, &$edit, &$user, $category = NULL) {
return; //new, just disable this function
...
?>
It's ugly cause it changes the core, but it's just one line. Anyway, core should have a simple function for disabling personal contact forms. Site wide contact forms still work fine.
Cleaner way
A much cleaner way to make the contact form go away for existing users (after it's been turned off in admin)
<?phpfunction mymodule_menu_alter(&$items)
{
unset($items['user/%user/contact']);
}
?>
Bye bye!
Would there be a method
Would there be a method (maybe via the menu_alter) to remove the personal contact form only for users in the authenticated user role, but not for other users like 'Editors' or 'Members'? It is important however that anonymous users still can access the global contact form / page.
The question contains the
The question contains the answer: Change the roles' permissions so that 'authenticated' can't 'access user profile.' There's a separate permission for 'access site-wide contact form.' You can distribute these permissions however you see fit.
This all lives at admin/user/permissions.
Enjoy. :-)
Disabling personal contact form from My Account > Edit
Hi,
I disabled the Contact module. I also have unchecked the admin/config/people/accounts: Enable the personal contact form by default for new users.
And every time I create a user, I also do not allow any contact form.
However, when the user logs in and goes to My Account, in the Edit option, there is a section which displays a checkbox to allow a personal contact form!
I dont want to display this to the user, what should I do?
My bad
My bad, turns out I had not unchecked the Contact from modules as I thought I did...
It sounds like the contact
It sounds like the contact module is still enabled if you're still being presented with those options. But if it truly isn't enabled, try uninstalling it (admin/modules/uninstall) and/or try clearing the cache. Hope that helps.