Title: Email Antispambot
Last modified: September 1, 2016

---

# Email Antispambot

 *  Resolved [irarab](https://wordpress.org/support/users/irarab/)
 * (@irarab)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/email-antispambot/)
 * I am trying to use antispambot to encode my email address in widget text using
   a short code as per [Function_Reference/antispambot
    
   
    My website is [legalmarketingplus.com](http://legalmarketingplus.com)
 * It is still under development. I tried to put my email in the header as “info
   AT legalmarketingplus.com”. This is in my functions.php
 *     ```
       /**
        * Hide email from Spam Bots using a shortcode.
        *
        * @param array  $atts    Shortcode attributes. Not used.
        * @param string $content The shortcode content. Should be an email address.
        *
        * @return string The obfuscated email address.
        */
       function wpcodex_hide_email_shortcode( $atts , $content = null ) {
       	if ( ! is_email( $content ) ) {
       		return;
       	}
   
               // Test to see what antispambot returns. This works.
               // I am getting encoded email.
              	$fh = fopen('/home3/digitalwiz/tmp/testlog.txt',"a+");
       	fwrite($fh,antispambot( $content ));
       	fclose($fh);
   
       	return '<a href="mailto:' . antispambot( $content ) . '">' . antispambot( $content ) . '</a>';
       }
   
       add_shortcode( 'email', 'wpcodex_hide_email_shortcode' );
   
       // You can also use this in a plain text widget if you add this filter to your function file as well.
   
       add_filter( 'widget_text', 'shortcode_unautop');
       add_filter( 'widget_text', 'do_shortcode');
   
       /*
       To use this in your WordPress Content area all you have to do it wrap it in a short code.
   
       [email]john.doe@mysite.com[/email]
   
       */
       ```
   
 * I put a test in to write antispambot( $content ) to a text file. It is writing
   the encoded email address to the text file but the source code has the regular
   email address. I am using the shortcode [email]. This is in widget text.
 * I checked using “Debug Bar Actions and Filters Addon” and the only callbacks 
   on widget_text are:
    - balanceTags
    - shortcode_unautop
    - do_shortcode
 * Thank you in advance for all of your help.

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Moderator [James Huff](https://wordpress.org/support/users/macmanx/)
 * (@macmanx)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/email-antispambot/#post-7635126)
 * Instead of using that, try an existing and supported plugin instead, like [https://wordpress.org/plugins/email-address-encoder/](https://wordpress.org/plugins/email-address-encoder/)
   or [https://wordpress.org/plugins/email-encoder-bundle/](https://wordpress.org/plugins/email-encoder-bundle/)
 *  Thread Starter [irarab](https://wordpress.org/support/users/irarab/)
 * (@irarab)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/email-antispambot/#post-7635129)
 * James,
 * Why did this not work?
 * I am using the Bridge theme from Qode
 *  Moderator [James Huff](https://wordpress.org/support/users/macmanx/)
 * (@macmanx)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/email-antispambot/#post-7635134)
 * I’m sorry, I don’t really have time to dig into the code right now, which is 
   why I suggested using existing and supported plugins instead.
 *  Thread Starter [irarab](https://wordpress.org/support/users/irarab/)
 * (@irarab)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/email-antispambot/#post-7635168)
 * It seems to be working now. Don’t know why is was not working before.
 *  Moderator [James Huff](https://wordpress.org/support/users/macmanx/)
 * (@macmanx)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/email-antispambot/#post-7635179)
 * That’s great to hear! 🙂

Viewing 5 replies - 1 through 5 (of 5 total)

 The topic ‘Email Antispambot’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [James Huff](https://wordpress.org/support/users/macmanx/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/email-antispambot/#post-7635179)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
