I'm trying to force a parallel identifier (to match up legacy system requirements) to correlate to uid by means of a field_data_field_foo table.

The field_data_field_foo was created in the Field UI and because I couldn't see any UNIQUE and AUTO_INCREMENT options I set them both for the column field_data_field_foo.field_foo_value in phpMyAdmin.

I assumed this would be enough to force the issue, but in development I setup a hook_user_presave() function in my custom module and with a break point inside it, for $account->field_foo I just get undefined....

field_foo   Array [1]   
    und Array [0]   

Because this is something that must be assigned uniquely and I'd like to assign at the point of registration should I be using a different hook? Or is there something else I'm missing?

Btw, it might be something more basic in Drupal that I'm missing as I'm not that experienced with it atm - i.e. due to the nature of this project, I've yet to spend time learning nodes and the like.

  • well, if you set the value in the database, you cant expect to see it in presave ?
    – mojzis
    Commented Oct 12, 2012 at 14:53
  • so the aim is to have another number independent of uid, do i get it right ?
    – mojzis
    Commented Oct 12, 2012 at 14:58
  • Yes, I want another unique number, independent of uid, which auto increments and can be assigned to every new user when they register.
    – ja_him
    Commented Oct 12, 2012 at 15:32
  • try adding a serial field to the user, but only ater they support entities other than nodes :(
    – mojzis
    Commented Oct 12, 2012 at 16:35

1 Answer 1


Here's what I did in the end...

First I added the field to the user registration form, as one thing Drupal is great at is processing information - I did notice errors being caught so I might have to check that out.

Then I used hook_user_presave() and (managing the unique id creation seperately) passed that, overriding any existing value or adding a value if none existed.

(full details are here: Editing user submission of user registration form with hook_user_insert() and $edit)

I will still have to manage away the users ability to insert an identifier by hiding it through CSS/JavaScript etc. but because hook_form_alter() wouldn't edit the user registration form after repeat attempts this seems the most expedient way of solving the problem.

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.