I have created a list of users with views and I can add the user email field. However, I don't want to show the full email address. Instead, I would like to show the first few letters followed by ****@domain.com. (e.g. patr***@gmail.com or kell******@yahoo.com)

The purpose is to help users remember what email address they used when creating an account without revealing the full address.

1 Answer 1


My solution for this is to go with adding a Views handler to the email field. The idea is to add a checkbox maybe saying "Mask part of the email address".

So you need to:

  1. Check the Views field handlers page for reference.
  2. You will see that there is a field handler for the user email which is called views_handler_field_user_mail. So this is what we need to add some settings and logic to "mask" parts of the email address.

That would be it. All you need to study now is how to structure and create the handlers and you can search for the guide you understand most but this(Drupal 7 Views 3 custom field handler) contains a good sample code too.

Of course the logic of masking the string/email will be all you already depending on your preferences or requirements.

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.