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
(@lab41)
Hi
I’ve tried that but it breaks the function.
http://screencast.com/t/8NbHMtsnF2iZ
It now adds a duplicate header area to my emails.
Alex
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.