Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Drupal.org currently uses a hack so that anonymous users can not use the personal contact form. Some details can be found in #362143: Review existing core patches, port what is still required.
There should probably be a new permission so that this behavior can be configured.
Comment | File | Size | Author |
---|---|---|---|
#11 | 371621.001.patch | 8.75 KB | karschsp |
Comments
Comment #1
webchickThis sounds like something that'd be pretty easy for a new contributor to do.
Comment #2
KarenS CreditAttribution: KarenS commentedI was just looking to see if there was an issue about this. I'll work on it if no one else does, but would be happy to see someone else do it.
Comment #3
Dave ReidThe 6.x contact module doesn't actually allow anonymous users to access the personal contact form by design. See #58224: Allow anonymous users access to a members personal contact form and _contact_user_tab_access():
Comment #4
David StraussThis is a usability issue. If we don't show users what they're not getting when they're anonymous, they won't have incentive to sign on and use such functionality. Plus, it's confusing to users who have been signed on and suddenly see missing options.
Comment #5
Dave ReidWe can't really add a new permission, because if the anonymous user does not have the permission, then they will get an access denied message, right? I tested the current behavior on d.org: going to user/1/contact as an anonymous users just showed me Dries' profile page (like at user/1). Is this the intended behavior? Let me know, I'd like to help with this d.org upgrade patch.
Comment #6
alexanderpas CreditAttribution: alexanderpas commentedsubscribing...
also, i think the user should be able to select who is able to contact him.
e.g.
Contact Settings:
- Hide Personal contact form
- Show Personal contact form to authenticated users only
- Show Personal contact form to everyone (only shows when site allows anonymous use of contact form.)
Comment #7
KarenS CreditAttribution: KarenS commentedThere are definitely situations where this would be desirable -- I have staff contact information that I *want* anonymous users to see and I *want* anonymous users to be able to access their contact forms. At the same time I have other users whose contact forms should not be visible to anonymous users. Currently Drupal won't let me control that, it hides contact forms from all anonymous users.
We need to add a new permission, then alter the code above to use the permission, something like:
But alexanderpas brings up a good point, there should maybe also be a way for the users to control this, so some change to the user edit form might be needed too, and that value should also be taken into account in the access formula.
Comment #8
alexanderpas CreditAttribution: alexanderpas commentedimproved _contact_user_tab_access some more ;)
Comment #9
David Strauss@alexanderpas There are at least two syntax errors in your post. Please fix and roll a proper patch. :-)
Comment #10
alexanderpas CreditAttribution: alexanderpas commented@#9
sorry, didn't have time... might do later...
Comment #11
karschsp CreditAttribution: karschsp commentedHere's a rough first stab at a patch based largely on @#8. I do a lot of
if ($user->uid != 0)
, not really sure if that's the best approach.Anyway, there's a new permission, 'access personal contact form' as well as a new option for authenticated users to choose whether or not they want anonymous users to have access. if an anonymous user goes to the contact page, assuming the correct permissions are set, they see textfields for "From" and "Email", however i'm using
variable_get('site_mail');
as the actual from: address.let me know if i'm on the right track.
thanks!
steve
Comment #12
Dave ReidThis issue is now officially duplicating the work done in #58224: Allow anonymous users access to a members personal contact form. Please merge your patch into that issue.
Comment #13
MakeOnlineShop CreditAttribution: MakeOnlineShop commentedAnd Do you know how i could hide the "Contact settings" and the tickbox in users account when users click Edit to edit their account ?
Thanks.