How to get the user's address?

Permalink
I want to display the user's address data, but until so far I only found $ui->getUserAddress(), which displays the whole address. Does anyone know how I can display address1, address2, postal_code etc. seperately?

 
jelthure replied on at Permalink Reply
jelthure
This should work for you:
$ak = UserAttributeKey::getByHandle('address'); //assuming the handle you gave the attribute is called address
if(is_object($ak)){
        echo $ak->getAddress1();
        echo $ak->getAddress2();
        echo $ak->getCity();
        echo $ak->getStateProvince();
        echo $ak->getCountry();
        echo $ak->getPostalCode();
}
marshe replied on at Permalink Reply
Hi jelthure

Thanks for your reply but it does not work. I get a fatal error because the methods $ak->getAddress1(); (etc...) are not recognized.
noXstyle replied on at Permalink Best Answer Reply
noXstyle
You can get the address fields by accessing AddressAttributeTypeValue object. i.e:

$ui = UserInfo::getByID ($uID);
$ui->getAttribute('address')->getAddress1();
$ui->getAttribute('address')->getCity();


etc. Might not be the best possible approach but at least it works fine.
marshe replied on at Permalink Reply
That works, many thanks!
bentvision replied on at Permalink Reply 2 Attachments
bentvision
Hi,

I don't mean to be a total n00b, but I'm having trouble and hope you can help me.

I too need to have the "billing address" fields separated into columns. I have tried many different mods to get concrete/tools/users/search_results_export.php to do this using the info that you provided. I'm failing hard. I'm not great at php but I'm learning.

I haven't found many other threads about this topic. Is there any hope of you pointing me in a good direction so that I can export my user data with all fields in their own column? Specifically the billing address fields from eCommerce?

Thanks for any help! I have attached my last stab at this "ME", which got me no where. And the original file I'm working with "good" from con5.

Jeff
ebrongers replied on at Permalink Reply
ebrongers
@Jeff
You can create a own handle billing address.

To export it with all the data in seperate fields on one row I guess you have to write your own export script. The default script may be working for you, but it does not export each row seperatly