Hi,
I am trying to update the appropriate module to allow users to who register for my site to automatically have the personal contact settings set so that they can send and recieve emails via the contact forms. I am new to Drupal and could really use a hand in getting sent in the right direction with this. I am not quite sure where I need make these updates. I have made tweaks on other modules to do other things so I understand the general structure etc. However, I am trying to figure out where I could trigger a change to the registration process that would auto-enable contact settings. Any suggestions would be wonderful and greatly appreciated!!!
My other thoughts were to create some sort of backend job to enable them on a cron but I figured I would try the more traditional approach first before resorted to a hack on the database.
Any help is greatly appreciated!
Thanks,
Frank
Comments
I believe...
That you can do this via the template engine or the contact.module itself. To do it via the module itself, you would need to add the code to handle the databse updates. In your case, and since it sounds like you will be doing this upon registration, you will have to add an if() statement to "function contact_user". This if() statement will need to handle the case "insert" in the same manner that the two for "form" and "validate" do. The contact_user function is called via drupal's hook_user when a user is registered with the case "insert" for the parameter "$type", so you will be able to perform your updates there.
You could also do it by adding a custom function to the phptemplate engine - if you are using that engine - but you can't use the hooks there - I think - as only themeable functions can be overridden. I may be wrong there, but I am 99% sure that's the case. So, in the actual contact.module you would add the following to the contact_user function:
The user info is passed by reference into that function via the "&$user" parameter. you may also want to check the value of the "$category" parameter, as it may or may not be relevant to what you want to do. I don't use that module so I haven't worked with it much.
Hope that helps.
-- aym
Simple way
If you want all users to have it on by default, then do this.
Edit contact.module.
Find function contact_user
Change
'contact', 1, $edit['contact']To
'contact', 1, 1That should do it.
--
Drupal development and customization: 2bits.com
Personal: Baheyeldin.com
--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba
Thanks...
For setting it straight.
-- aym
Actually, now that I think
Actually, now that I think of it, this may not work.
It will work if the user edits their account, but don't think it would work if they never visit it.
--
Drupal development and customization: 2bits.com
Personal: Baheyeldin.com
--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba
I've tested
It seems to turn contact forms on by default, but...
- There's no way to turn them off anymore. If users uncheck 'Personal contact form' and then save changes, when visiting the edit account page again the box will be checked, as if it was not modified.
- Users that have the contact form disabled prior to the contact.module change you suggested won't be able to turn it on, although it shows ON in his account settings.
Thus, this solution will only fit for new sites where ALL users must be ALWAYS available for contact. And even in these cases, as the option to turn contacts on/off is still available (although not working), it may lead to confusion.
Durval Tabach
Do you think this is possible?
Thanks you all for your help!! Is greatly appreciated!
Based on your feedback it sounds like I can turn the contacts forms "on" by default as mentioned but then I would have to somehow get rid of the hook that makes the user see the "contact settings" option on the profile page to avoid the confusion mentioned by dtabach. I really do not want users to have the option to be able to turn "off" contact forms so I am fine with removing the option from the account settings. So would that be possible by just removing a hook in the contact module? What do you guys think?
I just found the contact
I just found the contact settings hook_user() in the contact.module and changed it as follows after reviewing the Drupal module development documentation. I made the the form element into a selected radio button so it cannot be deselected. Here is the updated code for others to use if they want to do the same.
So users are automatically set to "Accept email contact policy" by default and should discontinue use of the site if they disagree with the sites email contact policy terms.
Really forced
It's no good thing to modify core modules directly, I guess... but I found a way to activate the personal contact form ONLY at the time a new user registers. And once registered, users can disable the option.
In user.module (drupal 4.6.3) at line 186 you can see this foreach cicle:
After that I added this piece:
Seems working!
And user can disable the function once they modify their profile.
It works
It seems to work well here.
Thanks.
This worked for me in 4.7
Thanks Rezzo, this worked for me in 4.7
__________________________
http://www.thomasturnbull.com
http://twitter.com/thomasturnbull
This works in 5.2!
I have just added that code bit for adding the contact info in 5.2 and it worked perfectly. And I'm not even a developer! Thanks all for adding info.
**Now I need to know how to send a mass email to all "contacts"? Anyone? Bueller???
DN
4.7
Got it working in 4.7 with the following code after line 205 of user.module
Find
if (strlen($name) > 56) return t('The username %name is too long: it must be less than 56 characters.', array('%name' => theme('placeholder', $name)));
}
and add the following after it
Doesn't that make every user
Doesn't that make every user an admin? Looks like a bad bad idea.
Feature request in - add comments to push it
messing around with code is way hairy for us non programmers - might break inupdates.
I've put ina feature request - support it with comments and lets get it done properly - maybe the code warriors can post their code their and when the Drupal Gods agree it's safe and correct, we'll have this function asap.
http://drupal.org/node/66648
Ian Dickson - community specialist.
Patch problem
Hello,
I know this is a newbie thing...I have tried to install the patch using the patch command but it throws an error:
[sydney:/Sites/fal] vincent% patch -p0 opt_out.patch
can't find file to patch at input line 8
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|Index: contact.module
|===================================================================
|RCS file: /cvs/drupal/drupal/modules/contact.module,v
|retrieving revision 1.36
|diff -u -r1.36 contact.module
|--- contact.module 13 Dec 2005 18:49:47 -0000 1.36
|+++ contact.module 16 Dec 2005 06:01:03 -0000
--------------------------
File to patch: /Sites/fal/modules/contact.module
patching file /Sites/fal/modules/contact.module
Hunk #1 FAILED at 78.
Hunk #2 succeeded at 144 with fuzz 2 (offset 43 lines).
1 out of 2 hunks FAILED -- saving rejects to file /Sites/fal/modules/contact.module.rej
I don't know what to do?? I am using the latest version 4.7.2 but the patch won't apply...Any idea?
Default contact setting to true
I believe this is the best current way to do it. This checks to see if the value is "unset," meaning the user hasn't made a choice. The only drawback is that when the user goes to their settings page, it will appear unchecked - but if they submit that page it will be saved as unchecked and they will no longer be contactable. This is acceptable to me for now. I'm sure if I hacked around I could find how to make that box appear checked when there is no setting in the database (as with a new user).
The fix is in modules/contact/contact.module, about line 548. Add the "isset" part to look like this:
How do I enable it for all
How do I enable it for all users in Drupal 5.1?
i want to enable it for everyone by default
it wld be nice to enable this for everyone by default. I have a similar need in the Guestbook also :)
anyways..one thing at a time..
later..maybe someone can deactivate..but yes..the danger of not having checkbox shown is bad :(
This Module Might Help
Hey all,
This module might help some of y'all:
http://drupal.org/project/privatemsg
or this one:
http://drupal.org/project/contact_anon
Jeremy
How to activate the personal contact form by default
How to activate the personal contact form by default
Hi,
I would like all my new members to have the personal contact form activated by default on Drupal 6, do you know how to do ?
Thanks.