Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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!

share|improve this question
    
I suggest you take a look into the very easy to use wordpress.org/extend/plugins/contact-form-7 instead of reinventing the wheel, although I don't know what you're really aiming for without looking at it. Perhaps you can provide a link? –  soulseekah Oct 18 '11 at 12:40
1  
As-written, this really isn't a WordPress -related question. –  Chip Bennett Oct 18 '11 at 12:44
    
@Chip Bennet As there's a template tag/core function for that, it's imo valid and wp related. –  kaiser Oct 18 '11 at 14:21
    
@kaiser as-written, this question asks about HTML form fields, putting email addresses into hidden form fields, and using the PHP mail function. It could be written in a way that is WordPress related, but it isn't currently. –  Chip Bennett Oct 18 '11 at 14:30
1  
I've attempted a re-write, to make the question more WordPress-specific. –  Chip Bennett Oct 18 '11 at 14:44

2 Answers 2

up vote 0 down vote accepted

Core function to obfuscate mail addresses:

antispambot( $emailaddy, $mailto );

Second arg is 0 or 1 and optional.

share|improve this answer
    
Oh! Is this what the OP was asking? Okay, let me attempt an edit to the question to make it more clear. –  Chip Bennett Oct 18 '11 at 14:40
    
I guess so. I already deleted my answer containing info about the wp_mail() function as I missunderstood it in the first place. –  kaiser Oct 18 '11 at 15:50
    
If you want to update your answer to discuss wp_mail(), I can delete mine. :) –  Chip Bennett Oct 18 '11 at 16:09
    
No. It's ok to have different answers to cover the whole topic :) –  kaiser Oct 18 '11 at 17:09
    
Thanks guys! Question was not clear enought because I didn't know if WP had built-in ways to solve the problem, but antispambot sure will do! –  teocomi Oct 18 '11 at 17:16

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.