0

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.

1
  • 2
    I dont think there is any module for this. You could try hook_form_alter to add your values.
    – niksmac
    Apr 24, 2013 at 7:23

2 Answers 2

2

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 :)

0

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.

3
  • 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, 2013 at 9:10
  • 1
    True, if something you can do through admin UI you should choose this way first.
    – Codium
    Apr 24, 2013 at 10:09
  • 1
    @drupality Only if it's exportable ;-)
    – Chapabu
    Apr 24, 2013 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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