Email Obfuscation Shortcode

There are a num­ber of rea­sons why you might want to dis­play an email address in a post: pro­vid­ing your own con­tact infor­ma­tion, pro­vid­ing a sup­port con­tact for a com­pa­ny or prod­uct you’re writ­ing about, and so on.

How­ev­er, sim­ply includ­ing an email address in your post is sim­ply ask­ing for an email har­vester to nab it, adding it to a spam­mer’s database.

Word­Press has a func­tion for obfus­cat­ing email address­es, mak­ing it all the more dif­fi­cult for the spam­mer’s to nab them with a harvester.

To add a short­code to your The­sis-pow­ered Word­Press install, sim­ply drop the fol­low­ing 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 sim­ple as it gets. Usage: 






2 responses to “Email Obfuscation Shortcode”

  1. Avinash D'Souza Avatar

    The only thing scary about actu­al­ly using an email address is that the spam­bots get THAT much smarter each day. It just takes one.… :)

    This is nifty nev­er­the­less. Also, love the The­sis spe­cif­ic bits of code!

  2. Rick Beckman Avatar

    Ide­al­ly, i rec­om­mend using reCAPTCHA’s Mail­Hide ser­vice to obfus­cate email address­es; how­ev­er, i’m not quite sure how to eas­i­ly turn it into a Word­Press short­code. When i do, i’ll be post­ing it.

    You’re right, though; the email har­vesters are get­ting bet­ter all the time, which is why i encour­age every­one to par­tic­i­pate in Project Hon­ey Pot.

Join the Discussion

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

Use your Gravatar-enabled email address while commenting to automatically enhance your comment with some of Gravatar's open profile data.

Comments must be made in accordance with the comment policy. This site uses Akismet to reduce spam; learn how your comment data is processed.

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>

Rick Beckman