SDAC Blog

Read our latest blog posts, learn something new, find answers, and stay up to date.

Create Anti-Spam Email Address in WordPress

I recently found a gem in the WordPress documentation. If you are looking for a way to display an email address but you do not want to use the actual email address because you are worried about spam, worry no more. Check out the “antispambot()” function that we have in WordPress. This function will take the email address that you want to use and obfuscates it. When you view the page you see the actual email address. When you view the source you do not see you see an encoded email address.

Example
In the example below – I will am using the WordPress function “antispambot” to create a mailto link for the post author (this would go in the loop).

<a href="mailto:<?php echo antispambot(get_the_author_meta('user_email')); ?>">Email the Author</a>

Further Documentation
http://codex.wordpress.org/Function_Reference/antispambot