By Michael Bevia on Wednesday, 30 December 2015
Posted in General
Likes 0
Views 0.9K
Votes 0
Hello, I am trying to echo the country value by the name of the user in the profile header.

I am putting this <?php echo $user->getFieldData('COUNTRY'); ?>

But I only get the ES, I would like to get the word of the country, ie. Spain

I cannot figure out how to echo this.
Hey Michael,

I am sorry for the delay of this reply,

But I've tried in my local, it should display `Spain` when I using this following code :
echo $user->getFieldData('COUNTRY');


Perhaps you can take a look of my screenshot below and see is it your current situation similar with me?
·
Thursday, 31 December 2015 11:19
·
0 Likes
·
0 Votes
·
0 Comments
·
Hey there,

It seems like your code is correct, but may I know what is this variable $user you call?

By the way, perhaps you can try follow my code and see how it goes?

First you have to make sure your custom field unique key is called 'COUNTRY' (you can double check this from your backend > Easysocial > profile type > select your profile type > custom field tab > edit country custom field > advanced tab )


$id = JRequest::getInt('id' , null);
$my = Foundry::user($id); // current user profile id
$customField = $my->getFieldValue('COUNTRY');
echo $customField;

·
Wednesday, 30 December 2015 10:18
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello, thank you for your reply, I checked the Unique Key and its country "COUNTRY"

So it echos the Region Code correctly, "ES"

But I would like to echo the "Region Name" of the country, Spain

Your code echos the Region Code, so I am just trying to see if its possible to echo the Region Name
·
Wednesday, 30 December 2015 11:00
·
0 Likes
·
0 Votes
·
0 Comments
·
You could probably do something like this,

·
Wednesday, 30 December 2015 12:45
·
0 Likes
·
0 Votes
·
0 Comments
·
Mark wrote:

You could probably do something like this,



Hello, sorry, I am not good with PHP, how would I put this? I tried this but got an error

<?php SocialFieldsUserCountryHelper::getCountryName($user->getFieldData('COUNTRY')); ?>
·
Thursday, 31 December 2015 01:06
·
0 Likes
·
0 Votes
·
0 Comments
·
What error are you getting?

Try this,

·
Thursday, 31 December 2015 01:29
·
0 Likes
·
0 Votes
·
0 Comments
·
Mark wrote:

What error are you getting?

Try this,



I tried this:

<?php require_once(JPATH_ROOT . '/media/com_easysocial/apps/fields/user/country/helper.php');

SocialFieldsUserCountryHelper::getCountryName($user->getFieldData('COUNTRY')); ?>

But nothing shows up
·
Thursday, 31 December 2015 01:40
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Arlex, okay, now its working. I was using the dropdown list...But I changed to textboxlist and now it shows the name of the country

Thanks very much!
·
Thursday, 31 December 2015 11:50
·
0 Likes
·
0 Votes
·
0 Comments
·
You'er welcome, glad to heard your issue resolved.
·
Thursday, 31 December 2015 11:56
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post