filters - wp_mail - Remove sitename from email subject

Can someone tell me how to remove site name from the email subject.As of now my email subject looks like this:[sitename]

Can someone tell me how to remove site name from the email subject.

As of now my email subject looks like this:

[sitename] - Subject goes here

I want it to look like this:

Subject goes here

I checked the wp_mail() code. There is a wp_mail filter available.

Can someone tell me how to use that filter to alter my email subject?

Can someone tell me how to remove site name from the email subject.

As of now my email subject looks like this:

[sitename] - Subject goes here

I want it to look like this:

Subject goes here

I checked the wp_mail() code. There is a wp_mail filter available.

Can someone tell me how to use that filter to alter my email subject?

Share Improve this question edited Mar 28, 2019 at 12:55 butlerblog 5,1313 gold badges28 silver badges44 bronze badges asked Sep 30, 2013 at 23:06 PrivateUserPrivateUser 3,46910 gold badges54 silver badges85 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 7

Finally, I wrote some code and it worked very well.

I hope it helps.

Put this in your functions.php file

//remove sitename from email subject
add_filter('wp_mail', 'email_subject_remove_sitename');
function email_subject_remove_sitename($email) {
  $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
  $email['subject'] = str_replace("[".$blogname."] - ", "", $email['subject']);    
  $email['subject'] = str_replace("[".$blogname."]", "", $email['subject']);
  return $email;
}

That file didnt work for me I had to it in wp-includes/pluggable.php

if ( isset( $atts['message'] ) ) {
    //$message = $atts['message'];
    $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
  $subject = str_replace("[".$blogname."] - ", "", $subject);    
  $subject = str_replace("[".$blogname."]", "", $subject);
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745649941a4638201.html

相关推荐

  • filters - wp_mail - Remove sitename from email subject

    Can someone tell me how to remove site name from the email subject.As of now my email subject looks like this:[sitename]

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信