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.
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityBy 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 :)
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.
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?
hook_form_alter
to add your values.