Show Me Your Email Module

Events happening in the community are now at Drupal community events on www.drupal.org.
kepford's picture

I have been been working on my module development chops recently and I created a very simple module for a very specific use. I respect and appreciate Drupal's privacy settings such as not displaying user info by default. In fact Drupal's core User and Profile modules do not allow you to show your user's email address at all. Only user's with the administer user's permission can see a user's email address. And they have to be editing a user account to even see it then. I know you can show email addresses with Views and there are other methods that allow you to display user addresses on your site but I wanted a permission based setting that would allow me to show user email addresses on the profile pages. I looked on Drupal.org and didn't find a module to accomplished it so I wrote one.

If you would like to take a look at this very simple module and possibly use it even, you can find it on Github(As of this writing I do not have a CVS account to post it on Drupal.org) http://github.com/kepford/showmeyouremail

Constructive advice is welcome.

Comments

Might want to change

redndahead's picture

Might want to change this:

return t('<a href="mailto:' . check_plain($account->mail) .'">' . check_plain($account->mail) . '</a>');

to

return l(t(check_plain($account->mail)), 'mailto:' . check_plain($account->mail));

A little more drupalistic.

The l() function does the

redndahead's picture

The l() function does the escaping for us and the email address should never need translating so you can change it to this.

return l($account->mail, 'mailto:' . $account->mail);

Thanks @redndahead.

kepford's picture

Thanks @redndahead.

just what I was looking for

plugandpray's picture

any chance to port this to drupal7?

Are you using it on a Drupal

kepford's picture

Are you using it on a Drupal 6 site now? I wasn't planning on porting it to 7 any time soon but I can. You can replicate the functionality of this very simple module if you use the views module. That said, this module is great if your aren't using Views module because it is really simple and small. But, I don't think I've ever built a site that didn't use Views.

no, I started using druapl

plugandpray's picture

no, I started using druapl this year, when version 7 was released. I even tried to port your module to version 7, but I havent zero experience with the development of drupal modules.
Anyway, with your module, if I select to display the email in the profile page, only users with access to the profile page can see the email, right? How can I do this with views? Sorry for the noob question, and thanks for ur reply.

No worries. Everyone is a

kepford's picture

No worries. Everyone is a noob when they start using something new. I created my module so that I could have a specific permission for viewing user email addresses. You can do the same with Views. When you create your view you want to set the "access" to either a specific role like "authenticated user" or to a permission. Have you used Views yet?

Ok. I get it. Doing it now.

plugandpray's picture

Ok. I get it. Doing it now. Thanks for your sugestion. :P

yes, Im using views. I found

plugandpray's picture

yes, Im using views. I found the option to set up access but, how I do to each user profile have a unique address, like the current user/uid? What option I must set up to achieve this?

Fresno

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: