如何仅为管理员关闭WordPress中的新用户通知电子邮件

时间:2016-10-05 11:27:53

标签: wordpress

我正在使用register_new_user操作来禁用管理员的电子邮件通知,但是当用户注册时,它仍会向管理员生成电子邮件。

我正在使用 Gravity Forms 进行用户注册

这是我的代码。

remove_action('register_new_user', 'wp_send_new_user_notifications');
add_action('register_new_user', 'ecpd_send_new_user_notifications');

function ecpd_send_new_user_notifications($user_id, $notify = 'user') {
    wp_new_user_notification($user_id, null, $notify);
}

非常感谢任何帮助。

2 个答案:

答案 0 :(得分:0)

我认为Gravity表单插件会覆盖您的默认设置。首先,据我所知,您可以在仪表板上显示默认通知电子邮件的管理员通知。

你可以通过重力形式设置来改变它:

https://www.gravityhelp.com/documentation/article/configuring-notifications-in-gravity-forms/

您还可以在gform_notification上使用挂钩。参考文献在这里:

https://www.gravityhelp.com/documentation/article/gform_notification/

答案 1 :(得分:0)

我终于想通了......

  1. 创建文件disable-new-user-emails.php
  2. 插入以下代码

    <?php /*
    Plugin Name:  Disable New User Email Notifications
    Description:  Using GravityForms Registration Add-on and Custom Notifications? This will Disable the Default WordPress Admin and User Notifications.
    Author:       BeHappy in 2017
     */
    
    if ( ! function_exists( 'gf_new_user_notification' ) ) {
        function gf_new_user_notification( $user_id, $plaintext_pass = '', $notify = '' ) {
                    return;
                }
            }
    ?>
    
  3. 保存!!!
  4. 将其上传到您的/ wp-content / plugins文件夹
  5. 激活插件
  6. 没有更多[网站]新用户注册电子邮件! :d
  7. 注意:我们正在使用GravityForms用户注册附加组件。为了让管理员或用户收到注册/欢迎电子邮件,您必须在表单的设置&gt;中为他们创建通知。通知

    最后,我还在运行MultiSite ......我有设置&gt;未注册的注册通知。我确信这个相同的代码适用于单个WP站点。