Title: Snippet Plugin Not Working
Last modified: August 22, 2016

---

# Snippet Plugin Not Working

 *  Resolved [Lab41](https://wordpress.org/support/users/lab41/)
 * (@lab41)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/snippet-plugin-not-working/)
 * When I use this snippet
 *     ```
       remove_filter( 'mandrill_payload', array($wp_better_emails, 'wpmandrill_compatibility') );
   
       // do your own email processing
       add_filter( 'mandrill_payload', 'wpbe_wpmandrill_compatibility' );
       function wpbe_wpmandrill_compatibility( $message ) {
   
           global $wp_better_emails;
   
           // make sure you have the %content% tag in the template
           if ( $wp_better_emails->check_template() ) {
               // clean < and > around text links in WP 3.1
               $message['html'] = $wp_better_emails->esc_textlinks( $message['html'] );
               // make links out of URLs
               $message['html'] = make_clickable( $message['html'] );
               // set template
               $message['html'] = $wp_better_emails->set_email_template( $message['html'] );
               // replace variables
               $message['html'] = apply_filters( 'wpbe_html_body', $wp_better_emails->template_vars_replacement( $message['html'] ) );
           }
   
           return $message;
       }
       ```
   
 * In my functions it works. But when I use it in your plugin it doesn’t work.
 * What am I missing?
 * [https://wordpress.org/plugins/code-snippets/](https://wordpress.org/plugins/code-snippets/)

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

 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/snippet-plugin-not-working/#post-5453633)
 * Quite possibly because snippets run at an earlier point in the WordPress load
   order then functions.php code. Try wrapping your `remove_filter` call in a function:
 *     ```
       add_action( 'init', 'wpbe_wpmandrill_compatibility_init' );
   
       function wpbe_wpmandrill_compatibility_init() {
       	remove_filter( 'mandrill_payload', array($wp_better_emails, 'wpmandrill_compatibility') );
   
       	// do your own email processing
       	add_filter( 'mandrill_payload', 'wpbe_wpmandrill_compatibility' );
       }
   
       function wpbe_wpmandrill_compatibility( $message ) {
   
           global $wp_better_emails;
   
           // make sure you have the %content% tag in the template
           if ( $wp_better_emails->check_template() ) {
               // clean < and > around text links in WP 3.1
               $message['html'] = $wp_better_emails->esc_textlinks( $message['html'] );
               // make links out of URLs
               $message['html'] = make_clickable( $message['html'] );
               // set template
               $message['html'] = $wp_better_emails->set_email_template( $message['html'] );
               // replace variables
               $message['html'] = apply_filters( 'wpbe_html_body', $wp_better_emails->template_vars_replacement( $message['html'] ) );
           }
   
           return $message;
       }
       ```
   
 *  Thread Starter [Lab41](https://wordpress.org/support/users/lab41/)
 * (@lab41)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/snippet-plugin-not-working/#post-5453691)
 * Hi
 * I’ve tried that but it breaks the function.
    [http://screencast.com/t/8NbHMtsnF2iZ](http://screencast.com/t/8NbHMtsnF2iZ)
 * It now adds a duplicate header area to my emails.
 * Alex
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/snippet-plugin-not-working/#post-5453693)
 * I forgot to add `global $wp_better_emails;` to the first function. Try this code
   instead:
 *     ```
       add_action( 'init', 'wpbe_wpmandrill_compatibility_init' );
   
       function wpbe_wpmandrill_compatibility_init() {
       	global $wp_better_emails;
   
       	remove_filter( 'mandrill_payload', array($wp_better_emails, 'wpmandrill_compatibility') );
   
       	// do your own email processing
       	add_filter( 'mandrill_payload', 'wpbe_wpmandrill_compatibility' );
       }
   
       function wpbe_wpmandrill_compatibility( $message ) {
   
           global $wp_better_emails;
   
           // make sure you have the %content% tag in the template
           if ( $wp_better_emails->check_template() ) {
               // clean < and > around text links in WP 3.1
               $message['html'] = $wp_better_emails->esc_textlinks( $message['html'] );
               // make links out of URLs
               $message['html'] = make_clickable( $message['html'] );
               // set template
               $message['html'] = $wp_better_emails->set_email_template( $message['html'] );
               // replace variables
               $message['html'] = apply_filters( 'wpbe_html_body', $wp_better_emails->template_vars_replacement( $message['html'] ) );
           }
   
           return $message;
       }
       ```
   
 * Also, make sure that you don’t have this snippet in your functions file as well
   as in the Code Snippets area, just in case.
 *  Thread Starter [Lab41](https://wordpress.org/support/users/lab41/)
 * (@lab41)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/snippet-plugin-not-working/#post-5453694)
 * Perfect!
 * Many Thanks!!!
 *  Thread Starter [Lab41](https://wordpress.org/support/users/lab41/)
 * (@lab41)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/snippet-plugin-not-working/#post-5453695)
 * Awesome1

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

The topic ‘Snippet Plugin Not Working’ is closed to new replies.

 * ![](https://ps.w.org/code-snippets/assets/icon.svg?rev=2148878)
 * [Code Snippets](https://wordpress.org/plugins/code-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/code-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-snippets/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Lab41](https://wordpress.org/support/users/lab41/)
 * Last activity: [11 years, 6 months ago](https://wordpress.org/support/topic/snippet-plugin-not-working/#post-5453695)
 * Status: resolved