When a site admin creates new user an e-mail gets sent with a one-time login link. However if a site admin forgets to tick the "Notify user of new account" box (which is not checked by default) the new account is as good as dead since the new user will never know about it.

How can we get this box to be checked by default?

Comments

villekahkonen’s picture

A client of mine specifically requested this, so I'd like to know too!

kkshivnarain@gmail.com’s picture

Subscribing

eusofzay’s picture

any function?

muddie’s picture

Would love this functionality.

lilnoma’s picture

same here

RKS’s picture

Check all of your core module files for user (probably user.module) and and search for the t string. I think it's something like "Notify user of..." Once you find the string it will have the checkbox and then the default_value will be false. So now you know what you have to override and the name.

Just add it to template in your theme and change the default_value to true.

vegardjo’s picture

Just had to do this. Create your own module, and in the .module file place

/* Hook form alter
 * Sets "notify user of new account" chosen by default
*/
function YOURMODULE_form_alter(&$form, $form_state, $form_id){
  if ($form_id == 'user_register_form') {
    $form['account']['notify']['#default_value'] = TRUE;
  }
}

Replace MYMODULE with the name of your module, and don't include the closing php tag. Enable it and you should be set!

(this for Drupal 7, BTW)

PoetCSW’s picture

Would someone consider simply making this a module for 7.x / 8.x that can be added to any install?

The only glitch I hit is creating the module info file. Can't be as troublesome as I'm finding it. Or can it be basically blank?

vegardjo’s picture

Try https://github.com/vegardjo/newacc (haven't tested it, but should work)

PoetCSW’s picture

Downloading to test.

PoetCSW’s picture

Ended up now getting lots of errors when I run the update script.

I installed the module manually (FTP'd to the sites folder) and it appears in the module list, but the moment I ran update it gives this:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'ProfileCrudTestCase-class' for key 'PRIMARY': INSERT INTO {registry} (name, type, filename, module, weight) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4), (:db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9), (:db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14), (:db_insert_placeholder_15, :db_insert_placeholder_16, :db_insert_placeholder_17, :db_insert_placeholder_18, :db_insert_placeholder_19), (:db_insert_placeholder_20, :db_insert_placeholder_21, :db_insert_placeholder_22, :db_insert_placeholder_23, :db_insert_placeholder_24), (:db_insert_placeholder_25, :db_insert_placeholder_26, :db_insert_placeholder_27, :db_insert_placeholder_28, :db_insert_placeholder_29), (:db_insert_placeholder_30, :db_insert_placeholder_31, :db_insert_placeholder_32, :db_insert_placeholder_33, :db_insert_placeholder_34), (:db_insert_placeholder_35, :db_insert_placeholder_36, :db_insert_placeholder_37, :db_insert_placeholder_38, :db_insert_placeholder_39), (:db_insert_placeholder_40, :db_insert_placeholder_41, :db_insert_placeholder_42, :db_insert_placeholder_43.......

PoetCSW’s picture

Okay, the error was caused by Profile 2. I upgraded to Profile 2 dev release and the issue went away.

I did take the liberty of changing the module to "Notify New" (notifynew), but otherwise left things as they were.

Wonderful fix!!!

peter.morlion’s picture

This works as intended, but causes some sort of conflict when you have user registration setup so that visitors can register, but they need approval by the admin. When enabling this module, a visitor that registers will receive the mail that his account has been created by the admin (instead of a mail saying it's waiting for approval). The admin gets no mail, but the user can't log in because the account hasn't been activated yet.

Looking at the code (I'm not a PHP guy), I'm guessing the checkbox is also checked when a visitor registers (even though this checkbox is then invisible).

winchendonsprings’s picture

Think this will work in D6? IS this really the simplest solution?

vegardjo’s picture

The hook_form_alter funcition hasn't changed from 6 to 7, so I believe this will work just fine in 6 too. There is no easier way to do this AFAIK.

thalemn’s picture

Hi,

I'm using D6 and the check box is NOT selected after installing the module.

Here's my code (I did not put the ?> in my module):

function user_customization_form_alter(&$form, &$form_state, $form_id) {
		if ($form_id == 'user_register_form') {
			$form['account']['notify']['#default_value'] = TRUE;
		}     
     }

Any thoughts??

Tom Hale
New Day Web Design
www.newdaywebdesign.com

benitezv1ang’s picture

how are we doing with this module any progress

jvieille’s picture

This module can very well enable the notification by default.
in genpass.module, function genpass_form_alter(), line 138:

    case 'user_register':
      $mode = variable_get('genpass_mode', GENPASS_DEFAULT);
+// Set "Notify user of new account" default ON
 +     $form['account']['notify']['#default_value'] = TRUE;
      // Add validation function, where password may get set
      $form['#validate'][] = 'genpass_register_validate';
     .. 

JV

jtattersall’s picture

In the file genpass.module line 138 is blank do a copy all this

    case 'user_register':
      $mode = variable_get('genpass_mode', GENPASS_DEFAULT);
+// Set "Notify user of new account" default ON
 +     $form['account']['notify']['#default_value'] = TRUE;
      // Add validation function, where password may get set
      $form['#validate'][] = 'genpass_register_validate';
     ..
yhancik’s picture

On D6 it should be

if ($form_id == 'user_register') {
            $form['notify']['#default_value'] = TRUE;
        }

:)

baig112233’s picture

Would someone consider simply making this a module for 7.x / 8.x that can be added to any install?

thalemn’s picture

Tom Hale
New Day Web Design
www.newdaywebdesign.com

martinciviac’s picture

Dear Tom,

Thanks a lot for that!
Unfortunately after downloading and trying to activate the module, I get the following error:
"This version is not compatible with Drupal 7.x and should be replaced."

Any ideas why?

BR,
Maria

MisterSpeed’s picture

I needed this myself so I created a new module now in contrib:

https://www.drupal.org/project/new_account_helper

The default value for Notify User of New Account can be defined in the standard Account Settings admin panel (Default Settings tab), and the value will only apply to users who have the Administer Users permission.

Enjoy !

webel’s picture

+1 definitely would like default for notification on creation of account by admin to be configurable (so can be set to true so not forgotten). Shame your nice little module only D7: https://www.drupal.org/project/new_account_helper

D8?

Webel IT Australia, "Elements of the Web", Scientific IT Consultancy,
For PHP-driven Drupal CMS web sites, Enterprise Java, graphical UML, UML Parsing Analysis, SysML, XML.

arshadkhan35’s picture

thanks vegardjo , its worked for me

firfin’s picture

Don't know if this is true for D7 also, but the first suggested simple solution of adding

 $form['account']['notify']['#default_value'] = TRUE;

 causes problems for me.  Specifically if users sign themselves up for an account, they get the 'new account notification email'. Not the 'waiting for approval' mail. This is counterintuitive if 'user, with admin approval' can make accounts.

hamrant’s picture

Code for D8:

/**
 * Implements hook_form_FORM_ID_alter().
 */
function MODULE_NAME_form_user_register_form_alter(&$form, FormStateInterface $form_state, $form_id){
  if (isset($form['account']['notify'])) {
    // Notify user by default on account creation.
    $form['account']['notify']['#default_value'] = TRUE;
  }
}
Gerard’s picture

Nice, you wouldn't have a module for a non developer?

Thanks in advance