0

I have been struggling to remove the wpautop filter from the retrieve_password_message function. I created a new email message and want to keep my <br>s instead of having automatic paragraphs added - since most email clients can't handle well <p> paddings or margins.

Any help?

  • I'm looking at the source code, and as far as I can tell wpautop is not applied to retrieve_password_message. In fact, the password reset email does not even appear to be an HTML email, so HTML tags wouldn't even work. – Jacob Peattie Jul 23 at 8:48
  • Well in fact it does add the p tags... I looked the source code myself, that’s why I’m here :) – scooterlord Jul 23 at 9:28
  • Source code of what wpautop()? I know, but where is it applied to the password reset email? – Jacob Peattie Jul 23 at 9:29
  • I checked the file where the wpautop filter is applied and there is no indication about emails. If you try the retrieve function though, it adds the tags :/ – scooterlord Jul 23 at 10:16
  • How do you know this is happening? If you’re inspecting the email in a web mail client then it’s more than likely added by the client so that it can render a plain text email in the browser. – Jacob Peattie Jul 23 at 10:19
0

Thanks to the constructive conversation with Jacob in the comments, I did some additional tests and realized that the <p> tags were in fact added by the plugin - testing in ive environment revealed that the email was plain text.

The solution to the problem was to add the following snippet in my functions.php:

function email_set_content_type(){
  return "text/html";
}
add_filter( 'wp_mail_content_type','email_set_content_type' );
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.