I’m writing a plugin that makes use of the wp_mail function. However I want to change the From: address. WP provides some filters – wp_mail_from_name and wp_mail_from – but I’m not sure how to call them from within a Class.
If I place them outside of a function there’s a parse error (unexpected T_STRING, expecting T_FUNCTION).
If I place them within a function nothing seems to happen
class myPlugin {
public function setFromname($fromname) {
apply_filters( 'wp_mail_from_name', $fromname );
$this->fromname = $fromname;
}
public function setFromemail($fromemail) {
apply_filters( 'wp_mail_from', $fromemail );
$this->fromemail = $fromemail;
}
}
How is it possible to affect these filters within a Class?
In WordPress filters must have a call back, they can not use a variable.