From debdc6713c509357d9090bad5504b6a782851864 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Fri, 24 Jun 2022 17:49:23 +0100 Subject: [PATCH] Enable the 'notify' parameter for WordPress user creation --- CRM/Utils/System/WordPress.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CRM/Utils/System/WordPress.php b/CRM/Utils/System/WordPress.php index d5e4e5dabf..928814f6d6 100644 --- a/CRM/Utils/System/WordPress.php +++ b/CRM/Utils/System/WordPress.php @@ -881,6 +881,12 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { 'role' => get_option('default_role'), ]; + // The notify parameter was ignored on WordPress and default behaviour was to always notify. + // Preserve that behaviour but allow the "notify" parameter to be used. + if (!isset($params['notify'])) { + $params['notify'] = TRUE; + } + // If there's a password add it, otherwise generate one. if (!empty($params['cms_pass'])) { $user_data['user_pass'] = $params['cms_pass']; @@ -939,8 +945,10 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { wp_signon($creds, FALSE); } - // Fire the new user action. Sends notification email by default. - do_action('register_new_user', $uid); + if ($params['notify']) { + // Fire the new user action. Sends notification email by default. + do_action('register_new_user', $uid); + } // Restore the CiviCRM-WordPress listeners. $this->hooks_core_add(); -- 2.25.1