WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm sending the content of a custom post type in a plaintext email (it's to send competition entries to a panel of judges), so I need to make sure that $post->post_content is correctly sanitised first.

Is there a filter I can use for this, or if not, what sanitisation do I need to do?

Update: I've just found wp_strip_all_tags in wp-includes/formatting.php, is this what I need?

share|improve this question
up vote 3 down vote accepted

You will want to use sanitize_email();

return( sanitize_email( $email ) );

Here is the Codex link so you have it: http://codex.wordpress.org/Function_Reference/sanitize_email


share|improve this answer
that's great thanks, exactly what i was looking for – Simon Blackbourn Apr 7 '12 at 12:57
Yeah, in the Professional WordPress Plugin Development by Wrox it explains in detail why it's best to use the sanitize_email function. There's also a validation function is_email which is really cool too. Cheers! – David Apr 7 '12 at 17:49

Your Answer


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.