I'm working on a View that displays a user's email field as a mailto. Given this is a recipe for spam, I'm wanting some way of obfuscating it.

I thought I'd go with Invisimail, but it (and seemingly ever other similar project) relies on a text filter. Given that the User email field doesn't use input formats, this makes it useless for my particular application.

I suppose I could create a separate email field, but I'd really like to not have to.

In short -- How do I obfuscate a user email field displayed via Views?


3 Answers 3


Spamspan module will help you. It can obfuscate email addresses from email fields along with emails provided inline in text.

For email field - chooses Spamspan formatter in display settings.

  • Hi Eugene, I have the same problem (listing users' email address in a view), however I'm not using a custom email field but just the existing user's account email field. I can't find any display settings for the account email field. Can I apply Spamspan to this email field?
    – Ben
    Commented Sep 4, 2012 at 9:50
  • Hi Ben, you can try. Commented Sep 5, 2012 at 8:05
  • Hi Eugene, I have tried without success.
    – Ben
    Commented Sep 5, 2012 at 12:17

To obfuscate the default users email field in a view you need to combine answers from Eugene and Eva.

  • install spamspan module
  • use the users email field in a view
  • copy the file views-view-field.tpl.php from [path_to_modules]/views/theme folder to your theme folder
  • change file name from views-view-field.tpl.php to views-view-field--mail.tpl.php
  • replace the default output in that file for the code snippet from Eva
  • clear theme cache

We use custom tpl.php file for the user account email field. In this field we have the following code:

if (function_exists('spamspan')) {
  print spamspan($output);
} else {
  print $output;
  • is this <?php tag really there, just before this call? If no, why put it here?
    – Mołot
    Commented Aug 15, 2015 at 15:36

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.