By icecreamyou on
I need a sitewide contact form, but I don't want my users to have contact forms because I'm using the Privatemsg module. The core contact module does not allow the administrator to turn off personal contact form functionality. So, is there another module I can use? Am I missing anything? If not, what do I need to do in terms of theming to just get rid of the Contact tab on user profiles?
I tried writing my own module to do this. It works 100% except that I can't get CAPTCHAs (from the CAPTCHA module) to work on it. If anyone could help with that, I'd be just as happy. :)
Thanks in advance.
Comments
I hope this can help
I hope this can help :)
d5.info
d5.module
I believe this little module can help as a start point. I have done it in a hurry, for sure it can be better.
Maybe someone else has a better solution for this...
Will that get rid of the tab
Will that get rid of the tab or just disallow users from seeing the contact page itself? (In other words, does Drupal do an access check before displaying tabs?)
And does it actually work to redefine a menu item? If so, how does Drupal know what order to process them in (i.e., it could read d5.module first, and contact.module after, and the access setting would change)?
I'm not 100% sure but...
->I think so. I've tested a little more in the function changing the conditional parameters (such as user_access('administer users') ) and it woks different.
You can set your own access permissions( hook_access ) for the module, and give them instead "false" that i gived to this module.
-> There should be a cross point for redefine a menu item. I'm not 100% sure if this is the correct way to do so, but it works for me.
-> I believe if you enable it later Drupal will proccess it later.
I have made a mistake with the code. It shouldn't be working for whatever $may_cache but when $may_cache is false.
Anyway , hook_menu is a bit weird :)
Thanks... will test soon.
Thanks... will test soon. Now I need to figure out how to best hide the Personal Contact Form on/off checkbox setting.
same module,
same module, hook_form_alter
first:
go to the page you want to change the form. The form_id and form will be displayed.
When you know the id and what you want to make dispear from the form, just alter the form
Maybe it would need more conditional programming...like if( !user_access('bla bla')) unsset($form['something']); or something like that.
Just wanted to post back
Just wanted to post back here to say it worked... thanks very much.
Here's what I ended up with for d5.module, minus the ?> at the end.
Will this code work in 6.*
Will this code work in 6.* version. If not then how i can turn it up for 6.x ?
No it won't, see hook_menu
No it won't, see hook_menu if you want to upgrade it.
.
In Drupal 6 is easier. You have there hook_menu_alter
I am finding this code very
I am finding this code very hit and miss. After I installed it it worked perfectly, then 24 hours later it had removed the contact tab (and permission) to the wrong set of users effectively allowing all the wrong people to access the personal contact form.
Any thoughts or suggestions?
Personally I'd completely remove the personal contact form from the contact module and put it into a second module in the core.
D6 hide personal contact form things
I'm using this (change "myd6module" to your own module name):
Hides the setting tickbox and the contact form, unless you are logged in with "administer users" permission.
http://www.fonant.com - Fonant Ltd - Quality websites
.info file
you'll need an info file to get it going. mine is below. i called the module "Hide Contact Tab" which is different than above. You can change it if you like:
; $Id: contact_tab.info,v 1.23 2008/12/08 01:26:54 thierrygd Exp $
name = Hide Contact Tab
description = "Hides the contact tab on user pages"
dependencies[] = contact
package = User interface
; Information added by drupal.org packaging script on 2008-12-08
version = "6.x-1.0"
core = "6.x"
project = "contact_tab"
datestamp = "1228700177"
Thanks!
Thanks for this. It worked great for my site!
heeeeeey works!
heeeeeey works!
Works great! Thank you!!!!!
Works great! Thank you!!!!!
D6 theme alter user profile form
Hi Thanks for the information, just what i needed.
After reading this comment and abit of further reading on http://www.lullabot.com/articles/modifying-forms-drupal-5-and-6
i realised i can hide the contact section without installing any module, but it is only specific to the specified theme.
Simply copy these code below into your theme's template file and clear your cache.
Also, This is for D6 just in case someone wonder.
I like the approach. The only
I like the approach.
The only thing I would change would be:
for
because when one uses
strposandifthe code won't be executed when strpos returns false(it doesn't find the string) or when strpos returns 0(the string is in the first position) and both cases are the opposite :)cheers
Ah.. thank you for pointing
Ah.. thank you for pointing that out :)
Getting this to work
Hi! Thanks for this I have been trying to find a way around this and have not been able to find a solution.
I copied your code into my template.php file and it still shows the contact tab in user profiles. What am I doing wrong!? Is this not the right file? Where specifically should I paste it?
Please help me out! I am using the basic Garland theme.
Okay got it.
I got it to work now. I think the issue was the change from if ( strpos($link,'/contact') ) { to if ( strpos($link,'/contact') === FALSE ) {. I did not put the false statement in and it's working fine.
Is there a way to do this so that administrators can still see the "contact" link? How else can or would an administrator contact a user?
add some user access
add some user access statement:
and
The mistake on the strpos, was:
Which is better for site performance/efficiency
Between the module solution to remove the personal contact form/tabs and the template.php solution, is one of these more or less burdensome to overall site performance?
...
this thread, especially patch at #6 might be of interest to some here: http://drupal.org/node/138574#comment-928203
i installed this module and it does the trick (for new users only).
Better way to remove users personal contact form option
Hi,
Is there any better way to remove users personal contact form option that they can see when they EDIT their account ?
Thanks to all.
Contrib module
Just stumbled upon https://drupal.org/project/contact_permissions, that does the trick for me.