$this->add('text', 'cms_name', ts('Username'), ['class' => 'huge']);
$this->addRule('cms_name', ts('Username is required'), 'required');
- // For WordPress only, comply with how WordPress sets passwords via magic link
+ // WordPress may or may not require setting passwords via magic link, depending on its configuration.
// For other CMS, output the password fields
- if ($config->userFramework !== 'WordPress' || ($config->userFramework === 'WordPress' && !$config->userSystem->isUserRegistrationPermitted())) {
+ if ($config->userSystem->showPasswordFieldWhenAdminCreatesUser()) {
$this->add('password', 'cms_pass', ts('Password'), ['class' => 'huge']);
$this->add('password', 'cms_confirm_pass', ts('Confirm Password'), ['class' => 'huge']);
$this->addRule('cms_pass', ts('Password is required'), 'required');
public function invalidateRouteCache() {
}
+ /**
+ * Should the admin be able to set the password when creating a user
+ * or does the CMS want it a different way.
+ */
+ public function showPasswordFieldWhenAdminCreatesUser() {
+ return TRUE;
+ }
+
}
add_action('profile_update', [$civicrm->users, 'update_user']);
}
+ /**
+ * Depending on configuration, either let the admin enter the password
+ * when creating a user or let the user do it via email link.
+ */
+ public function showPasswordFieldWhenAdminCreatesUser() {
+ return !$this->isUserRegistrationPermitted();
+ }
+
}