Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

Are there any modules available for adding more values to the standard Drupal user status?

By default we have "Active/Blocked" values, but I would like to extend it with more values.

share|improve this question
2  
I dont think there is any module for this. You could try hook_form_alter to add your values. – Nikhil M Apr 24 at 7:23

2 Answers

By default, I don't think there's any way of doing this. The user status is used by other parts of user.module (as well as x amount of contrib modules), so extending it could cause conflicts there.

What you could do however, is add a custom status field to your users and use that. You'll get most of the normal benefits of the Drupal user status, but it'll be as extensible as you need.

Combine it with Field Permissions to prevent users from being able to see or edit (or either one of those options) themselves should you need to.

The Field Permissions module allows site administrators to set field-level permissions to edit, view and create fields on any entity.

If you still want a user status that disabled the user account, then you could create a value on your custom status field (let's call it Disabled and then configure a Rule that says:

Event:

After saving a user account After updating a user account

Condition:

Use data comparison to se if *field_my_user_status* is equal to disabed

Action:

Block user account

*NB If you do this, don't forget to create an opposite rule that enables the user account based on your field value :)

share|improve this answer

You can add one more option to the status field using hook_form_alter and to keep a track for that extended status value.

You may need a database entry also, so you can add a CCK field to the user account, and when a user receives the extended value, simply update the CCK field value using a custom submit handler and finally calling user_save() inside it. This way you will always have a db entry for the extended option.

share|improve this answer
1  
It seems relatively counter intuitive to write code for a hook_form_alter (and a custom submit handler) to update a field type. Why not just use that field type as the status field and be done with it? – Chapabu Apr 24 at 9:10
1  
True, if something you can do through admin UI you should choose this way first. – drupality Apr 24 at 10:09
1  
@drupality Only if it's exportable ;-) – Chapabu Apr 24 at 10:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.