diff --git genpass.module genpass.module
index 0147a92272c213f1e246543f82228db8a685b06a..4874904e235510153d0a2440338935900d0c3426 100644
--- genpass.module
+++ genpass.module
@@ -106,6 +106,11 @@ function genpass_form_alter(&$form, $form_state, $form_id) {
'#default_value' => genpass_algorithm_module(),
'#options' => genpass_add_samples(genpass_algorithm_modules()),
'#description' => t('If third party modules define a password generation algorithm, you can select which one to use. Note that algorithms other than genpass will ignore the preferred entropy and password length. The currently selected algorithm produced the password @pw.', array('@pw' => genpass_generate())),
+ );
+ $form['registration_cancellation']['genpass_display_messages'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Display password generation messages'),
+ '#default_value' => variable_get('genpass_display_messages', 1),
);
$form['#validate'][] = 'genpass_user_admin_settings_validate';
// Move the "When cancelling a user account" field down.
@@ -183,18 +188,20 @@ function genpass_register_validate($form, &$form_state) {
$pass_item =& _genpass_get_form_item($form, 'pass');
form_set_value($pass_item, $pass, $form_state);
- // If administrator is creating the user, don't show the password
- // (for security reasons)
- if ($_GET['q'] == 'admin/user/user/create') {
- drupal_set_message(t('Since you did not provide a password, it was generated automatically for this account.'));
- }
- // Optional - User did not provide password, so it was generated
- elseif ($form_state['values']['genpass_mode'] == GENPASS_OPTIONAL) {
- drupal_set_message(t('Since you did not provide a password, the following was generated for you: !password', array('!password' => $pass)));
- }
- // Restricted - User was forced to receive a generated password
- elseif ($form_state['values']['genpass_mode'] == GENPASS_RESTRICTED) {
- drupal_set_message(t('The following password was generated for you: !password', array('!password' => $pass)));
+ if(variable_get('genpass_display_messages', 1)){
+ // If administrator is creating the user, don't show the password
+ // (for security reasons)
+ if ($_GET['q'] == 'admin/user/user/create') {
+ drupal_set_message(t('Since you did not provide a password, it was generated automatically for this account.'));
+ }
+ // Optional - User did not provide password, so it was generated
+ elseif ($form_state['values']['genpass_mode'] == GENPASS_OPTIONAL) {
+ drupal_set_message(t('Since you did not provide a password, the following was generated for you: !password', array('!password' => $pass)));
+ }
+ // Restricted - User was forced to receive a generated password
+ elseif ($form_state['values']['genpass_mode'] == GENPASS_RESTRICTED) {
+ drupal_set_message(t('The following password was generated for you: !password', array('!password' => $pass)));
+ }
}
}
return $form;