Editing user submission of user registration form with hook_user_insert() and $edit I recognize there is a similar question here: 

drupal.stackexchange.com/questions/38124/hook-user-insert-get-form-values 

but I've got Eclipse and XDebugger setup so I can see the variables and I am still stuck. 

I provide the variables below, please note field_foo is a field the system has taken care of properly without my interfering, after the user submits it, field_bar is a field I want to change the submitted value of, it has the value 303031 when the system handles it from form submission, where the variables show "value 300501 " is my attempt to edit that value - clearly I'm editing something wrong)

$edit   Array [37]  
[0...30]    
    uid 63  
    field_foo   Array [1]   
        und Array [1]   
            0   Array [1]   
                value   asdasd  
                    length  6   
                    0   61  
                    1   73  
                    2   64  
                    3   61  
                    4   73  
                    5   64  
    field_bar   Array [2]   
        und Array [1]   
            0   Array [1]   
                value   303031  
        value   300501  


Here is my code to try and set it...

function MY_MODULE_user_insert(&amp;$edit, $account, $category) {

    $newBarValue = 300501;
    $edit[field_bar][value] = $newBarValue;

}


PLEASE NOTE:

I don't know if this is the case for all field_data_field Core fields but I had to use the following to get it to work:

$edit[field_bar][und][0][value] = $newBarValue;

This might be unique as I am working on someone else's work atm.
hook_user_insert() is invoked after the user object and all it's fields have already been committed to the database; that's why your code isn't taking effect at the moment.

There are a couple of ways you could go:


Use exactly the same logic in hook_user_presave(), which gets called before the data is committed to the database.
Implement hook_form_alter() for the registration form, add a custom validation function, and manipulate the field values in there.