Email Obfuscation Shortcode

There are a number of reasons why you might want to display an email address in a post: providing your own contact information, providing a support contact for a company or product you’re writing about, and so on.

However, simply including an email address in your post is simply asking for an email harvester to nab it, adding it to a spammer’s database.

WordPress has a function for obfuscating email addresses, making it all the more difficult for the spammer’s to nab them with a harvester.

To add a shortcode to your Thesis-powered WordPress install, simply drop the following into your custom_functions.php file:

# Email obfuscation shortcode
function custom_email_shortcode( $atts , $content = null ) {
	return antispambot( $content );
add_shortcode( 'email', 'custom_email_shortcode' );

This is about as simple as it gets. Usage:

2 thoughts on “Email Obfuscation Shortcode

  1. Avinash D'Souza says:
    35x finance supergeek, 5x eco buff, 40x commonsenser, 20x enabler=100x authentic. Sum ergo cogito. But ego operor>ego cogito. So…what I can do for you today?

    The only thing scary about actually using an email address is that the spambots get THAT much smarter each day. It just takes one…. :)

    This is nifty nevertheless. Also, love the Thesis specific bits of code!

  2. Rick Beckman says:
    Student of the sciences, the religions, the science fictions, and the fantasies… But mostly I’m just trying to find my groove in this big, crazy world.

    Ideally, i recommend using reCAPTCHA’s MailHide service to obfuscate email addresses; however, i’m not quite sure how to easily turn it into a WordPress shortcode. When i do, i’ll be posting it.

    You’re right, though; the email harvesters are getting better all the time, which is why i encourage everyone to participate in Project Honey Pot.

Join the Discussion

Your email address will not be published. Required fields are marked *

Comments must be made in accordance with the comment policy. Use your Gravatar-enabled email address while commenting to automatically enhance your comment with some of Gravatar's open profile data.

You may use Markdown to format your comments; additionally, these HTML tags and attributes may be used: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>