set field value from function after user account edit/registering action I need to assign one custom field value from user profile. One field is nickname (this field is filled by user) and I need to generate another field with function.

The function takes nickname and using external library takes this nicknames ID. I need to run one function and save this ID everytime new profile is saved or existing updated.

I can not find good way to do it.

I tried with Rules module setting event after account updated with action evulate value with php, but there i can not load my api library to do the function.

Any information will help me
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)