Pre-populate field in content from user profile I'm trying to pre-populate a field in a new piece of content with a country field from a users profile. These are two different Drupal fields, but they are both using the location module so country codes should easily transferred between the two.

I have managed to verify the data from $field_country_you_co_ordinate_fo['und'][0]['country']), this prints the country code 'gb' as expected.

I can't pull the value into $form['field_location']. Tried several different chains of array keys based on the previous ticket linked at the bottom. I'm clearly misunderstanding the combinations of keys needed to pull from one variable to another, so any help would be greatly appreciated.

Thanks in advance

function perma_boot_form_organisation_node_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  // Only run against newly created node 

  if (empty($form['nid']['#value']) &amp;&amp; (!isset($form['#node']-&gt;op))) {
    global $user;
    $user_fields = user_load($user-&gt;uid);

    if (isset($user_fields-&gt;field_country_you_co_ordinate_fo['und'][0]['country'])) {
        //print_r ($user_fields-&gt;field_country_you_co_ordinate_fo['und'][0]['country']);
        $form['field_location']['und'][0]['country'] = $user_fields-&gt;field_country_you_co_ordinate_fo['und'][0]['country'];
    }
  }
}


Have been working from the previous example:
How to pre-populate fields on a node creation form based on fields from Profile2 module?
Firstly, thanks to all for the help. I followed your advice and configured devel to print $page. Followed the structure of the page and came up with the amended the code:

$form['field_location']['und'][0]['country']['#value']


Leaving Devel enabled, I can see the value has been set correctly to gb. However, this breaks the google map functionality.

On to the next problem :)