For my website I really have no need for the personal contact form. I saw the patch that allowed the access of the personal contact form to be set, but in that case, I don't want the other users to even see the 'Contact settings' in the user edit form. I'm sure there are many sites using Drupal that aren't actually community sites, so only a manager role or administrator role should be able to contact any users. The 'Contact settings' might just confuse these regular users and even make them think random people on the site might be contacting them. A way to turn off whether regular users can see this or not would be great.

Temporarily I've just changed the following in the contact_user function:

From -

if ($type == 'form' && $category == 'account') {

To -

if ($type == 'form' && $category == 'account' && user_access('access personal contact forms')) {

This works for my plans, but I thought I'd see if anyone else would need this feature and how it would best work for them. It is probably better to seperate this from the 'access personal contact forms', but this was just a quick fix for myself for now.

Cheers,
Steph

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nerissa’s picture

That is exactly what I needed for the site I am working on as well... THANK YOU!! Now I want to try and figure out how to do the same thing to get rid of the Locale settings under the Edit node tab. Thank you again, greatly appreciated! YAH!

Dave Reid’s picture

Title: Add ability to turn off personal contact form » Add permission to turn off personal contact form
Version: 5.7 » 7.x-dev

We should probably use some kind of permission for this. Moving to 7.x.

Dave Reid’s picture

Title: Add permission to turn off personal contact form » Add permission to *have* a personal contact form
doq’s picture

Assigned: Unassigned » doq
Status: Active » Needs review
FileSize
2.59 KB

Status: Needs review » Needs work

The last submitted patch failed testing.

Dave Reid’s picture

All you need for the upate function is just to add the permission to the authenticated user role:

function system_update_numberhere() {
  $ret = array();
  db_insert('role_permission')
    ->fields(array(
      'rid' => DRUPAL_AUTHENTICATED_RID,
      'permission' => 'new permission here',
    ))
   ->execute();
  return $ret;
}
doq’s picture

Status: Needs work » Needs review
FileSize
2.23 KB

Status: Needs review » Needs work

The last submitted patch failed testing.

flaviovs’s picture

Sorry, but this entire contact form issue is wrong from start.

To have a site-wide contact form (which I'm sure is a must to any site -- use it Drupal or not) and to be able to provide personal contact forms for your users are two entirely diferent use cases.

The correct path IMHO is to split the module in two: contact.module and personal_contact.module (or the like). Admins wanting only a site-wide contact form would enable only the former, while others wanting to provide personal contact forms for your users would enable only the latter.

I even bet this will also simplify the code a lot.

Just my $.02.

-Anti-’s picture

> Admins wanting only a site-wide contact form would enable only the former, while others
> wanting to provide personal contact forms for your users would enable only the latter.

I'm using drupal 6 and was looking for the answer to this.
I'm currently using this unofficial module provided by mattB:
http://drupal.org/node/138574#comment-928203
It enables you to turn off personal CFs, and leave the site-wide CF on.

Is this still my best option for D6?

I hope that whenever this feature gets looked at properly, Drupal ends up with a kick-ass contact system
for D7. The D6 contact form was obviously not prioritised over peripheral features like the color module.

flaviovs’s picture

I don't touch the contact module anymore for a long time. This personal contact "feature" is just a show-stopper for the sites I worked on recently, as none of then wanted to have to deal with personal contact forms.

All contact forms on the sites I create are now handled using the webforms modules. Webforms may sound overkill for the task, but it's the only alternative I know of, and it does the job very well.

There used to be a "feedback" module which provided site-wide personal with some other nice features (and without the hassles of the contact form), but it's know a discontinued project (don't use feedback2 — it's a completely different animal).

BTW, if you stick to the contact module you may want to take a look on the Contact no CC module, which removes the carbon copy checkbox (a "feature" which IMHO should also be provided by a separate module, or at least have a setting to be turned off).

Dave Reid’s picture

Version: 7.x-dev » 8.x-dev

Too late for D7, so bumping to D8.

robby.smith’s picture

subscribing

agerson’s picture

this would be a good distinction to make

freshwater’s picture

Awesome patch, does the job perfectly.

setvik’s picture

Status: Needs work » Needs review
FileSize
1.58 KB

uff-da. I made a patch before discovering this issue.

Rerolled the patch against 8.x, moved system_update_7036() to contact_update_8000(), and adjusted some wording.

It would be great to get something like this into core; For every site i build, I enable the site contact form and then disable the personal contact form in code.

Exposing this as a permission would rock.

Status: Needs review » Needs work

The last submitted patch, contact-personal-contact-form-permission-254460-16.patch, failed testing.

setvik’s picture

Status: Needs work » Needs review
FileSize
1.55 KB

ack. rogue semi-colon. re-rolling.

Liliplanet’s picture

thanx, is the D8 patch valid for D7 as well?

Would most appreciate this feature in D7 :)

yoroy’s picture

Issue tags: +permissions

tag

theamoeba’s picture

The patch in #18 seems to be failing on a Drupal 8.0-dev minimal install:

theamoeba@~/development/drupal8> git apply -v contact-personal-contact-form-permission-254460-18.patch
Checking patch core/modules/contact/contact.install...
Checking patch core/modules/contact/contact.module...
error: while searching for:
'#title' => t('Contact settings'),
'#weight' => 5,
'#collapsible' => TRUE,
);
$form['contact']['contact'] = array(
'#type' => 'checkbox',

error: patch failed: core/modules/contact/contact.module:220
error: core/modules/contact/contact.module: patch does not apply

setvik’s picture

amontero’s picture

Patch became stale. Rerolled manually just copypasting.
Code looks OK. Tested and works as advertised. Needs tests, so tagging.
Would this be backportable to 7.x? As long as we keep the appropiate update hook, looks like it's safe to.
In such case, we may also add a link meanwhile to this issue somewhere in this page: http://drupal.org/documentation/modules/contact

amontero’s picture

Stale. Reroll chasing HEAD.

Status: Needs review » Needs work
marcingy’s picture

+  db_insert('role_permission')
+    ->fields(array(
+      'rid' => DRUPAL_AUTHENTICATED_RID,
+      'permission' => 'administer own contact form',
+    ))
+    ->execute();

Needs to be in its own update function not an existing one.

amontero’s picture

Status: Needs work » Needs review
Issue tags: +Novice
FileSize
2.08 KB

Done.

amontero’s picture

Assigned: doq » Unassigned

Unassigning.

marcingy’s picture

Status: Needs review » Needs work

Looks good just needs some tests now :)

amontero’s picture

Status: Needs work » Needs review
FileSize
2.04 KB

Here are them. They're supposed to fail. Full patch will follow.

Status: Needs review » Needs work
amontero’s picture

Status: Needs work » Needs review
FileSize
4.13 KB

Full patch.

joris_lucius’s picture

I tested this in a clean D8 install.

  • User X/Y are able to change their own settings depending on the "Administer own personal contact form" permission
  • User X cannot contact Y when Y has disabled the checkbox.
  • User X can contact Y when Y has enabled the checkbox
  • User X/Y cannot use the personal contact form if the "Use users' personal contact forms " is not set

However there still seems to be one "issue".
If "Administer own personal contact form" is disabled the uses will never know other persons are able to send them emails using this Drupal site. The "Use users' personal contact forms" can be set.

This way user X can send emails to user Y and user Y cannot disable this.
Like I said this might not be important.

amontero’s picture

Issue tags: -Needs tests

Thanks for thorough testing, Joris.
The purpose of this permission is to remove any user control of personal contact forms. The site admin would set the default personal contact form to either on or off and force it via this permission.
I see no side effects neither on defaulting PCF to on or off anyway and forcing it, altough it sounds a bit "spammy". But that's up the site builder/admin, IMO.
This was mainly for addressing the "no-PCF for anybody" use case. Are you thinking in any particular use case where it has side effects?
TIA.

amontero’s picture

(double submit, sorry)

marcingy’s picture

Issue tags: +Needs tests

This still needs tests as in simple test

marcingy’s picture

Status: Needs review » Needs work
marcingy’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests

Doh my bad I missed the last patch :(

joris_lucius’s picture

No, not an use case in particular.
Was just mentioning it because it is an option.
I agree it is an admin issue

amontero’s picture

Patch became stale. Reroll.

rootwork’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +SprintWeekend2013
FileSize
12.21 KB
16.62 KB
33.12 KB

Patch applies and confirmed that this works as expected, as noted in #33 (and clarified in #34).

Here's what the permissions look like:

permissions.png

Here's admin (user1) viewing user2. Admin has the permission to use users' contact forms:

admin-viewing-user2.png

And here's user2 viewing admin. As only an authenticated user, user2 does not have the permission to use users' contact forms, even though admin's contact form is enabled:

user2-viewing-admin.png

Personally, I think the phrasing of the permission, "Use users' personal contact forms," is a little cumbersome. I'd prefer something like "Use personal contact forms of users who enable them," or if that's too long, "Use personal contact forms" as the permission, with "Use the personal contact form for users who enable it" as the help text.

But since that's just my personal opinion on wording, I'm going to go ahead and mark this as RTBC and if someone higher up than me wants to quibble with the language, they can :)

amontero’s picture

Thanks a lot for the detailed review. The "Use users' personal contact forms" text might be improved, but that should be dealt with in another issue, since this patch only adds the "Administer own personal contact form" permission.

(To core gatekeepers) Also, this patch seems an easily backportable one if we add an update hook that grants this new permission to those already having the "Administer contact forms and contact forms settings".

xjm’s picture

Status: Reviewed & tested by the community » Needs work

The last submitted patch, drupal--254460--add-administer-own-contact-form-perm-40.patch, failed testing.

xjm’s picture

Status: Needs work » Needs review
Issue tags: +permissions, +Novice, +SprintWeekend2013
xjm’s picture

+++ b/core/modules/contact/contact.installundefined
@@ -110,6 +110,19 @@ function contact_update_8003() {
+ * Set permission so the personal contact form's "Contact Settings" does
+ * not disappear from user account pages when upgrading from 7.x to 8.x

Oops, let's fix this summary so that it's only one line of 80 characters or fewer: http://drupal.org/node/1354#functions

amontero’s picture

Fixed.
Would love to get feedback about #42 when this one gets commited.

xjm’s picture

(To core gatekeepers) Also, this patch seems an easily backportable one if we add an update hook that grants this new permission to those already having the "Administer contact forms and contact forms settings".

I don't think we can actually backport this. Consider this scenario: Someone has already implemented this functionality in a contrib or custom module. Our update hook runs and suddenly all users that previously did not have access are granted it, causing a security issue.

xjm’s picture

Also, do we maybe want to default to this permission being granted when contact is installed?

amontero’s picture

Too bad, I didn't thought on the scenario you explain in #48. Let's leave it for contrib.
As for #49, I can imagine valid reasons to enable it on install. However, I grepped for hook_installs in other modules and granting some permission on install would be a first, and I can also think of valid reasons of installing with it off by default depending on the use case. Maybe install profiles are the right place?
Additionally, the usual 'secure by default' kinda of reasoning would leave this off and since 8.x is a brand new Drupal, one can expect some default behavior changes and this will allow discovering the new feature.
Of course, I might have overlooked some reason behind your proposal and would love to know more of it.

mvg33’s picture

This was a great thread! Now, lets so it again for D7 :) I need this patch!!

amontero’s picture

Status: Needs review » Needs work
Issue tags: +permissions, +Novice, +SprintWeekend2013

The last submitted patch, drupal--254460--add-administer-own-contact-form-perm-47.patch, failed testing.

amontero’s picture

Status: Needs work » Needs review
FileSize
4 KB

Reroll, awaiting for feedback on default permission setting on #50. Again, some changes in freshly installed sites configuration are to be expected in a new version. Why not let users discover the new permission?
Anyway, Drupal 8 will have a long release notes file ;)

Status: Needs review » Needs work
Issue tags: -permissions, -Novice, -SprintWeekend2013

The last submitted patch, drupal--254460--add-administer-own-contact-form-perm-54.patch, failed testing.

amontero’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
Issue tags: +permissions, +Novice, +SprintWeekend2013

The last submitted patch, drupal--254460--add-administer-own-contact-form-perm-54.patch, failed testing.

amontero’s picture

Issue tags: +Needs reroll

Tagging

amontero’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
3.97 KB

Reroll, awaiting for feedback on default permission setting on #50. Again, some changes in freshly installed sites configuration are to be expected in a new version. Why not let users discover the new permission?
Anyway, Drupal 8 will have a long release notes file ;)

Status: Needs review » Needs work

The last submitted patch, drupal--254460--add-administer-own-contact-form-perm--59.patch, failed testing.

amontero’s picture

Status: Needs work » Needs review
FileSize
4.05 KB

Reroll of #59, awaiting feedback on #50.

Status: Needs review » Needs work

The last submitted patch, drupal--254460--add-administer-own-contact-form-perm--61.patch, failed testing.

amontero’s picture

Status: Needs work » Active

Setting to active to get feedback on #50.
Also, found https://drupal.org/project/contact_permissions on contrib.

brad.bulger’s picture

This may be outside the scope of this issue, but if the intent is to allow administrators to take management of personal contact forms out of the hands of users, should there be any better support for that? Some way to tell who has forms enabled and who does not, and perhaps to be able to enable/disable forms in batch?

illeace’s picture

Issue summary: View changes
Issue tags: -Novice

Removing the "Novice" tag since this looks like it needs feedback from a more experienced dev.

Anonymous’s picture

Still relevant. I too don't want my users to choose if they want personal contact form or not. Just hide the setting behind a permission just like it was before.

andypost’s picture

the related should be affected by the issue

andypost’s picture

Version: 8.0.x-dev » 8.1.x-dev
Status: Active » Postponed

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

brad.bulger’s picture

Status: Postponed » Needs work

Seven years is long enough.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.