0

I want to be able to set specific permissions by role for the use of the Personal Contact Form.

Searching drupal.org shows a few modules to work with Contact forms, but none do what I am looking to do, so I'm wondering if I'm overlooking something simple.

What I would like to do:

Role A

  • Can have own Personal Contact form BUT it is only available to other Authenticated Users
  • Can access and use Personal Contact form for any other user (Role A or Role B)

Role B

  • Can have own Personal Contact form available to Anonymous AND Authenticated Users
  • Can access and use Personal Contact form for any other user (Role A or Role B)

Anonymous Users

  • Can only access Personal Contact Form for Role B Users, NOT Role A Users.

The idea is that Role B Users have the privilege of allowing the public / anonymous users to contact them via the Personal Contact Form, but all Authenticated Users should be able to contact each other using the form.

Should I do this with the Webform module? Or is there some permission setting for the Personal Contact Form I am missing?

I don't want it to be binary (either you have a Personal Contact Form or you don't), but I want some types of users to be able to access some other users Personal Contact Form.

1 Answer 1

0

I would do this using hook_form_alter.

Set up your roles, then create a function using hook_form_alter that checks if it's building the contact form or not. If building the contact form, check the current user's role, and either redirect to a 403 or allow it to go through.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.