WordPress.org

Forums

wpMandrill
Edit Flow n2lbr problem with mixed html and plaintext emails (4 posts)

  1. Peter Martin
    Member
    Posted 1 year ago #

    Problem: we have a mix of HTML (Gravity Forms, Woocommerce) and plain text (Edit Flow) notification emails that are routed through Mandrill.

    We can't use the "Content" checkbox, as it will add needless line breaks to the HTML emails, which go through to our users.

    The fix provided in Mandrill documentation (n2lbr filter) doesn't appear to be working for us. We tried using the "forgot passwords" filter as a test, as provided by Mandrill here:


    function forgotMyPasswordEmails($nl2br, $message) {
    if ( in_array( 'wp-retrieve_password', $message['tags']['automatic'] ) ) {
    $nl2br = true;
    }
    return $nl2br;
    }
    add_filter( 'mandrill_nl2br', 'forgotMyPasswordEmails' );

    No dice. Forgot password email came through broken, no line breaks.

    Ditto with the Edit Flow specific filter we worked out:


    function forgotMyPasswordEmails($nl2br, $message) {
    if ( in_array( 'wp-retrieve_password', $message['tags']['automatic'] ) ) {
    $nl2br = true;
    }
    return $nl2br;
    }
    add_filter( 'mandrill_nl2br', 'forgotMyPasswordEmails' );

    This had no effect.

    We also tried this mandrill_payload filter (source):


    function op_mandrill_payload($message) {
    // Add wpautop to message content
    $message['template']['content'][0]['content'] = wpautop($message['template']['content'][0]['content']);
    return $message;
    }
    add_filter('mandrill_payload', 'op_mandrill_payload');

    To reduce the potential complicating factors, we've switched to the twenty fourteen theme and deactivated all plugins except wpmandrill and Edit Flow.

    We've also tried loading the filters in two different ways: 1, via the functions.php in twenty fourteen; 2, via an mu-plugin file.

    Nothing seems to have any effect. Any ideas?

    https://wordpress.org/plugins/wpmandrill/

  2. Peter Martin
    Member
    Posted 1 year ago #

    bump.

  3. Inkline
    Member
    Posted 9 months ago #

    Did you ever end up finding a solution. Exact same issue here. $message doesn't seem to have a value inside the filter, although the filter does fire.

  4. burt
    Member
    Posted 8 months ago #

    Two things:

    1. The tag name starts with "wp_"
    2. Set the number of variables passed to the filter function.

    Try this:

    function forgotMyPasswordEmails( $nl2br, $message ) {
      if ( in_array( 'wp_retrieve_password', $message['tags']['automatic'] ) ) {
        $nl2br = true;
      }
      return $nl2br;
    }
    add_filter( 'mandrill_nl2br', 'forgotMyPasswordEmails', 10, 2 );

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • wpMandrill
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic