禁用管理员在每次新用户注册时收到的电子邮件(功能不起作用)

时间:2013-01-17 作者:Desi

我的函数中有以下函数。php。我试图禁用管理员在每次新用户加入网站时接收电子邮件。然而,管理员仍在接收电子邮件。功能是否有问题?这是WP选项的一部分吗?我在任何地方都找不到这个选项。

// Disable New User Reg Emails
if ( ! function_exists( \'wp_new_user_notification\' ) ) :
    function wp_new_user_notification( $user_id, $plaintext_pass = \'\' ) {

        /** Return early if no password is set */
        if ( empty( $plaintext_pass ) )
            return;

        $user       = get_userdata( $user_id );
        $user_login = stripslashes( $user->user_login );
        $user_email = stripslashes( $user->user_email );

        // The blogname option is escaped with esc_html on the way into the database in sanitize_option
        // we want to reverse this for the plain text arena of emails.
        $blogname = wp_specialchars_decode( get_option( \'blogname\' ), ENT_QUOTES );

        $message  = sprintf( __( \'Username: %s\' ), $user_login) . "\\r\\n";
        $message .= sprintf( __( \'Password: %s\' ), $plaintext_pass) . "\\r\\n";
        $message .= wp_login_url() . "\\r\\n";

        wp_mail( $user_email, sprintf( __( \'[%s] Your username and password\' ), $blogname ), $message );

    }
endif;

2 个回复
最合适的回答,由SO网友:akTed 整理而成

您需要提前实现您的功能。似乎“真正的”wp\\u new\\u user\\u notification()(来自wp includes/pluggable.php)是在您的之前创建的。要进行测试,请拆下if ( ! function_exists( \'wp_new_user_notification\' ) ) : 从您的代码。你应该得到一个错误。

您可以创建一个插件:

//Plugin Name: blahblah
function wp_new_user_notification() {
  // your code
}
或者,只需将该代码放在它自己的代码中。php文件并将其放入wp-content/mu-plugins目录中(如果不存在则创建)。这个问题应该得到解决。

SO网友:NW Tech

有一个插件可以处理禁用新用户注册的问题:http://wordpress.org/extend/plugins/disable-new-user-notifications/

结束

相关推荐