1
I configured in the nail the wp-mail function of the wordpress responsible for sending emails on the site through the form. If wordpress update I have to make this addition of codes again in function?
1
I configured in the nail the wp-mail function of the wordpress responsible for sending emails on the site through the form. If wordpress update I have to make this addition of codes again in function?
1
If wordpress update I have to make this addition of codes again in function?
If Wordpress updates your edits will be lost, it is not a good practice to change the files of the core
(nothing out of the briefcase wp-content
).
How to solve?
The function wp_mail()
is the type pluggable
, as the file name says. This means that it is only executed in the original if another function is not specified with the same name.
// wp-includes/pluggable.php` linha 142 no WP 4.7
if ( !function_exists( 'wp_mail' ) ) :
function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() )
So just create a new function called wp_mail()
in a plugin
or mu-plugin
, with your custom code - which can be a copy of the original with your change -, and your version will be used in place of the original.
Thank you very much. I am already here creating a plugin for this and want to install it in all my applications that uses wordpress to not have headache later.
Browser other questions tagged php wordpress function
You are not signed in. Login or sign up in order to post.
"I set up in the nail" what exactly did you do? changed the
wp-includes/pluggable.php
?– Ricardo Moraleida
That’s right, I added this class:
class email_return_path {
 function __construct() {
 add_action( 'phpmailer_init', array( $this, 'fix' ) ); 
 }
 
 function fix( $phpmailer ) {
 $phpmailer->Sender = $phpmailer->From;
 }
}
 
new email_return_path();
– WPfan