MyBB Community Forums

Full Version: [MyCode] hidden email from bots
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I needed to give my email to users on a public post, but don't want to be spammed too much, and don't want to use a temporary address.

So I did this little MyCode which replace the visible email by a less visible (with [AT] and [DOT] inside) and creates a link only usable with javascript.

Note that I used an image from MyBB in the style, feel free to adapt the style as you need.

Regexp
([A-Z0-9._%+-]+)@([A-Z0-9.-]+)\.([A-Z]{2,4})

Replacement
<a href="#" rel="nofollow" style="padding: 1px 0px 1px 23px; background: url(/images/usercp_sprite.png) no-repeat;" onclick="this.href='mailto:' + '$1' + '@' + '$2' + '.' + '$3'">$1 [AT] $2 [DOT] $3</a>

Example
[attachment=33874]