我想禁用用户注册时发送的默认电子邮件。我正在使用此插件进行电子邮件验证User Verification
By PickPlugins, 它发送带有确认链接的电子邮件,但问题是默认情况下,WordPress通过pluggable.php:
function wp_new_user_notification( $user_id, $deprecated = null, $notify = \'\' ){...}
我正在使用一个主题(我正在扩展一个子主题),它调用
wp_create_user. 我已经替换了父主题函数
functions.php 我补充道:
add_action( \'init\', function(){
remove_action( \'register_new_user\', \'wp_send_new_user_notifications\'
);
add_action( \'register_new_user\', \'wpse236122_send_new_user_notifications\' );
});
function wpse236122_send_new_user_notifications( $user_id, $notify = \'user\' ){
wp_send_new_user_notifications( $user_id, $notify );
}
问题是,它仍然会发送来自插件的电子邮件和用于新用户注册的默认WordPress电子邮件。我不知道如何禁用此电子邮件。
SO网友:JonShipman
将参数default移到函数中。
add_action( \'init\', function() {
remove_action( \'register_new_user\', \'wp_send_new_user_notifications\' );
});
add_action( \'register_new_user\', \'wpse236122_send_new_user_notifications\' );
function wpse236122_send_new_user_notifications( $user_id ){
wp_new_user_notification( $user_id, null, \'user\' );
}
将wpse236122\\u send\\u new\\u user\\u notifications函数更改为使用wp\\u new\\u user\\u通知,而不是直接使用操作。尽管它可以工作,但更有可能在WordPress更新中中断。
我还想提到的是,使用register\\u new\\u user操作并设置为较低的优先级,而不是删除init上的操作。WordPress core默认使用10,所以将您的值设置为9或更低就可以了。
add_action( \'register_new_user\', function(){
remove_action( \'register_new_user\', \'wp_send_new_user_notifications\' );
}, 9);