我需要阻止网站上的任何用户创建电子邮件,我尝试覆盖负责邮件发送的任何可插入功能。唯一有效的是
$this->loader->add_filter( \'send_password_change_email\', $users, \'disable_email\' );
$this->loader->add_filter( \'send_email_change_email\', $users, \'disable_email\' );
thedisable_email
方法定义在Users
班class Users {
/**
* Function that will disable email sending when user is created
*
* @return bool False.
*/
public function disable_email() {
return false;
}
...
}
the$users
只是Users
类别,以及$this->loader
是的实例Loader
类,它保存筛选器。但是当我创建WordPress用户时,我想阻止\'New User Registration\'
管理员和用户将获得的邮件。
我读到的是,我应该能够重写可插入函数,但唯一的方法是在插件的根文件中,在任何类之外定义它们。
所以我试过了
if( ! function_exists( \'wp_new_user_notification\' ) ) {
function wp_new_user_notification( $user_id ) {
return false
}
}
但是检查我的邮件收集器(我使用的是VVV),它不起作用,因为邮件仍在通过。我甚至试着覆盖wp_mail()
功能相同,但什么都没有发生。邮件仍在处理中。
我没有主意了。我需要阻止邮件,但我不知道怎么做:/