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 would wish to add a filter to _e() and __() functions. The filter is FilterTextOfEmail(). This will basically detect any emails and add anti-spam method to it.

I assume, the function for filtering should look like:

function my_wp_text_email_filtering ($content) {
    return FilterTextOfEmail($content)

But how to call it?

share|improve this question
Could you provide more context on what is you're trying to archieve? Is FilterTextOfEmail an example function name, or does that function literally exist? More details and clarification of the question please.. – t31os Dec 21 '11 at 21:54
up vote 8 down vote accepted

The filter name is gettext, and you would add it like this:

add_filter( 'gettext', 'my_wp_text_email_filtering', 10, 3 );

function my_wp_text_email_filtering( $translated, $text, $domain ) {
    return FilterTextOfEmail( $translated );

The $text argument is there also in case you want to access the pre-translated text.

share|improve this answer
Thank you for answering, works great. However, what would be the filter for the the_content() as it appears, __() and _e() don't automatically apply for that. – Kalle H. Väravas Dec 22 '11 at 11:23
Not sure what you're asking here? You just want to apply the same filter to the_content? Wouldn't add_filter( 'the_content', 'FilterTextOfEmail' ); work for that? – goldenapples Dec 22 '11 at 19:37
Yes, your are correct! Thank you! – Kalle H. Väravas Dec 22 '11 at 21:00

You have to filter 'gettext'. See this answer for an example.

Always check the textdomain parameter to avoid conflicts with plugins and themes.

share|improve this answer
Thank you for answering – Kalle H. Väravas Dec 22 '11 at 11:22

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.