I need to create an auto-generated value for every user on my site. No one should be able to edit this field so it should not appear on the user edit form. Is there a better way to achive this than simply removing its edit field with hook_form_alter?

2 Answers 2


Install the Field Permissions module:

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

And the Computed Field module:

Computed Field is a very powerful CCK field module that lets you add a custom "computed fields" to your content types. These computed fields are populated with values that you define via PHP code. You may draw on anything available to Drupal, including other fields, the current user, database tables, you name it.

You can then create a field for your value, hide it from the registration/profile form, and use Computed Field to set its value to whatever you need it to be automatically.


I would use Field Extra Widgets that provides a "Hidden" widget which is probably what you're looking for.

In any case, instead of removing the field with a unset or alike, it's better to do an #access => FALSE in the form alter.

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.