7 – Update the author_uid for an entity record

I am looking to update the author_uid for an Entity Registry in Drupal 7 programmatically. I want to replace all the anonymous users with the UID of 0 for another UID, say 2 when saving the record. I have tried three different solutions so far in vain.

Solution 1) Update the author_uid in $ form_state before saving the registration form.

<? php
function registration_form_alterations_form_alter (& $ form, & $ form_state, $ form_id) {

if ($ form_id == "registration_form") {
dpm ($ form);
dpm ($ form_state);
$ form['#submit'][]    = & # 39; registration_form_alterations_custom_submit & # 39 ;;


function registration_form_alterations_custom_submit ($ form, & $ form_state) {
// send the code of the handler
dpm ($ form_state);

This did not work because author_uid is not available to be modified in form_state to the best of my knowledge.

Solution 2) Update through hook_entity_presave. I'm not sure this works because I can not seem to isolate the real registrar to update the author_id in hook_entity_presave.

Solution 3) Use rules … What does not allow you to update the author_uid. A rule message screen returns with a message about the value that can not be written / edited.

Does anyone have any additional ideas about this? I'm sorry, I know it's a bit of a strange request, but we have a user who wants to have anonymous records reassigned so they can manage the additional details associated with the records.