最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

email - Remove wpautop from retrieve_password_message

programmeradmin4浏览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 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?

Share Improve this question asked Jul 23, 2020 at 8:10 scooterlordscooterlord 1137 bronze badges 6
  • 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 Commented Jul 23, 2020 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 Commented Jul 23, 2020 at 9:28
  • Source code of what wpautop()? I know, but where is it applied to the password reset email? – Jacob Peattie Commented Jul 23, 2020 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 Commented Jul 23, 2020 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 Commented Jul 23, 2020 at 10:19
 |  Show 1 more comment

1 Answer 1

Reset to default 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' );
发布评论

评论列表(0)

  1. 暂无评论