This is my first bug out here. Not sure it is a bug or a feature enhancement. :(..

I tried to create a normal user using the admin account and wanted to make that user to be blocked initially. But, the user is not getting blocked even though i select "blocked" as the status. Instead, the user gets created with "active" status.

Steps to reproduce:
1. Login as "admin" user
2. Select "Administer > User Management > Users"
3. Click "Add User"
4. Give any value for username, password and email
5. In the status section, set the status as "blocked"
6. Click "create new account" and check the list of users page

I digged into source code and analysed data passed to user_save function in modules/user/user.module,

Line 2616: $account = user_save('', array_merge($form_values, array('pass' => $pass, 'init' => $mail, 'roles' => $roles, 'status' => ($admin || variable_get('user_register', 1) == 1))));

This particular condition,

($admin || variable_get('user_register', 1) == 1)

always yields 1 (which is the active status). I dont know how to tweak it to work out.. :(..

CommentFileSizeAuthor
#2 user_adminstatus.patch1.7 KBChrisKennedy
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ChrisKennedy’s picture

Status: Active » Needs review

Confirmed that this is a bug in user_register_submit(). Attached patch fixes it.

I performed four tests:
1. Admin && status == blocked -> blocked.
2. Admin && status == active -> active.
3. User && user_register == 1 -> active.
4. User && user_register == 2 -> blocked.

So it appears to work as intended.

ChrisKennedy’s picture

FileSize
1.7 KB

Here's the patch.

Steven’s picture

Status: Needs review » Fixed

Tested and verified. Good job, committed to HEAD.

Anonymous’s picture

Status: Fixed » Closed (fixed)