Hi,
I want save user address programmatically, i am using address field for this.
I am creating user pro-grammatically and saving address like this
$account = user_load(2);
$entity = entity_metadata_wrapper('user', $account);
//field_profile_address is the name of the address field
$entity->field_location->thoroughfare = '123 test lane';//address
$entity->field_location->premise = 'Apt. 2G';//address 2, apt #
$entity->field_location->locality = 'Brooklyn';//city
$entity->field_location->administrative_area = 'NY';//state
$entity->field_location->country = 'US';//country
$entity->field_location->postal_code = '11226';//zip
$entity->save();
This is not working, anyone did this ?
Thanks
Deepak
Comments
Comment #2
bojanz CreditAttribution: bojanz at Centarro commentedThis should work fine, postal_code is not different from the other fields.
What do you get when you dsm() the saved address?
Comment #3
1kenthomas CreditAttribution: 1kenthomas as a volunteer and commentedArray ( ) [field_address] => Array ( [und] => Array ( [0] => Array ( [country] => US [administrative_area] => MD [sub_administrative_area] => [locality] => Testville [dependent_locality] => [postal_code] => 01267 [thoroughfare] => 1 Main St [premise] => Apartment X [sub_premise] => [organisation_name] => [name_line] => [first_name] => [last_name] => [data] => ) ) )
I am using user_save() but seem to have no issue.