Recently, I was looking for a way to have a clients website allow logged in users to contact one another but still maintain some level of privacy so that their personal email addresses were not readily available and susceptible to spam, etc. So, what I decided that I needed to do was allow users to utilize Drupal’s internal contact forms in order to contact one another.
For example, when reading a post by another user, logged in users can use the users personal contact form to contact them and send the posts author a message.
My example uses some fancy content access permissions and I utilize a specific content type that only users with specific permissions can access. This content type has its own custom template (e.g. in D7, the theme template would be: node--example_content_type.tpl.php
) and I found a nice little snippet to include in the custom template that pulls the authors contact form. For more on creating a custom node template, I appreciate Lin Clark’s tutorial will reference her screen-cast which helped me a lot when I was a beginner and learning what templates could do – http://lin-clark.com/blog/intro-drupal-7-theming-fields-and-nodes-templates.
Then, I just simply added the following snippet into my custom template with its own custom CSS. It’s pretty simple and I think you can find all sorts of possibilities to securely contact a content author…
Simply put this code between an opening <?php tag and a closing ?> tag:
echo l('Click here contact this author.', "user/$node->uid/contact");
Hope you find it useful!