I want to get, modify and return the message of the sending emails in WordPress with a function.
I tried with gettext filter with no results. I tried wp_mail filter where I feel is a better approach but I can not get this to work.
add_filter('wp_mail','edit_email', 10,1);
function edit_email(){
$args['message']=str_replace( 'foo', 'bar', $args['message'] );
return $args['message'];
}
In this filter function, return $args
instead of just $args['message']
:
add_filter('wp_mail','edit_email', 10,1);
function edit_email($args){
$args['message'] = str_replace( 'foo', 'bar', $args['message'] );
return $args;
}
Edit: added $args as a function argument.