1

I need to assign custom ids for all users. The Id will come from API and its depend on other filled by user custom field. Witch hook should I use and witch variable holds id value?

2 Answers 2

0

I presume you're referring to a login ID - you should be able to use hook_form_alter to access the registration form, and create a default value.

get Devel module and use dpm($form) in that function to look through the array to find the exact element you want to change.

after that you can probably use a number of options to hide the element, including css so that the user can't change it before being submitted.

0

Are you looking to add a secondary ID field, separate from UID? If so, the user entity is fieldable, and you could probably use hook_user_update or hook_user_presave to populate the field, using aggregated the data from other user fields.

If I follow you correctly, it would be something like 'field_1 + field_2' comprise the new "ID" field you're creating. In which case, one of these hooks will achieve what you're looking for. Feel free to provide further clarification if needed.

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.