set field value from function after user account edit/registering action
Have you tried hook_user_presave() ?

https://api.drupal.org/api/drupal/modules!user!user.api.php/function/hook_user_presave/7

You have access to all fields of your new user and can pick up your value, call your custom code and get your new id. Then add it wherever you need to.

Use dpm($account) to inspect your user object.(devel module)