0

I'm building a module that has to sync users with another, non-drupal, db. When the hook_user_update is run I check to see if the user has an account in the other db. If they don't then it creates a record there and returns their id from that system. The problem I have is now I need to store that new id in a custom drupal field as well. I don't want to assign it and call user_save inside of hook_user_update because I don't want to run another instance of hook_user_update before the other has finished running. So, is it possible to just save a single user field without having to call user_save thus triggering hook_user_update?

1

field_attach_update() may do what you need

https://api.drupal.org/api/drupal/modules%21field%21field.attach.inc/function/field_attach_update/7

A comment on the API doc page mentions using it to update a node's fields without updating the node.

If your custom field isn't part of the user object, you may just need to use drupal_write_record to write your field data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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