I’m writing a WP Theme where registered users can email post authors sending them en email from the post’s page itself.
So I created a contact form in which I get the user and author infos and emails and I put them in hidden input fields to pass them to the php mail function.
Does WordPress have a way to obfuscate the post author’s email address, to protect it from scrapers? Is there a better way to implement this functionality, other than outputting the author email address in the form field?
Thanks!
Core function to obfuscate mail addresses:
Second arg is 0 or 1 and optional.
You could alternately use the
wp_mail()
function to send the commenter’s email on form submission. That way, the post author’s email address never has to be exposed publicly in the form field to begin with.