The Movable Type Knowledge Base

Show Email Addresses Of Commenters

Question

Sometimes my commenters don't leave a URL, so I want to show their email address instead. How can I display these?

Answer

The default templates use the <MTCommentAuthorLink> tag to provide a link for each commenter. In version 3.16 of Movable Type, the default behavior for displaying email addresses was changed. Now, the rules for the linking are as follows:

  • If the author has entered a URL, the author name will be a link to that URL.
  • If no URL was entered, display the author name without a link.

You can override these rules to also include the option to show the email address, by adding the show_email attribute to the tag. For example, if you use:

<MTCommentAuthorLink show_email="1">

then the email address of the author can be displayed. The logic then becomes:

  • If the author has entered a URL, display the author name as a link to that URL.
  • If the author has entered an email address, but no URL, display the author name as a link to the email address.
  • If neither email address nor URL are entered, display the author name without a link.

Given the prevalence of spam, you may want to reconsider publishing email addresses on your site, as many of your visitors will not be happy with this practice. But, if you do decide to display these, add the spam_protect attribute to afford some extra protection:

<MTCommentAuthorLink show_email="1" spam_protect="1">

By using the spam_protect attribute, any displayed email address will be modified so as to prevent spambots from harvesting it. The web browser, however, will still display the email address properly.

For example, if the email address is foo@bar.com, then the attribute will cause the email address will be displayed as foo@bar.com in the source HTML.

Note: There is a Known Issue with version 3.16 where the show_email="1" does not behave as expected. You should upgrade if you wish to use this feature.

Submit Feedback on This Article

Your comments on how we can improve this article are appreciated; but please do not use the feedback form to submit support requests or questions. We will not respond to or publish such queries submitted through this form. If you have a technical question or problem, visit Movable Type Support.

Yahoo! Small Business web hosting services

Six Apart
Makers of weblog software and services for individuals, organizations and businesses.
This website is powered by Movable Type.