By Gene Teigland on Thursday, 09 July 2015
Posted in General Issues
Likes 0
Views 1.2K
Votes 0
I appreciate all the help so far but having an issue when trying to incorporate the code for a custom field.

On this link you have this:
http://stackideas.com/docs/easysocial/developers/users/users

On the bottom you have the topic:
Setting custom field value (1.2)
With directions for the code:
equire_once( JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php' );
$my = Foundry::user();
$state = $my->setFieldValue( $key , 'some value here' );


I have integrated except replacing "some value here" with my key id and that data does not show.

Now I've been able to grab other data using your directions as indicated in this forum:
http://stackideas.com/forums/es-api-implementation-for-users

If you read that we were able to do this with unique code to grab the user id url string ...
See sample below:
$userIdRaw = JRequest::getVar('user_id');
$userId = strstr($userIdRaw, ':', true) ?: $userIdRaw;
echo Foundry::user($userId)->getName();


So here are the two issues (know that I've been able embed other data from you API ) but cannot with custom field.

1. I tried to just put in your code as I described above except replacing 'some value here' with my key id which in this case was key id "TEXTBOX-1" from custom field found in:
Profile types/Undergraduate/Education/College or University
The code you showed in your api did NOT work.

2. Ideally I would love to code to match what we are doing in the post http://stackideas.com/forums/es-api-implementation-for-users as I'm sharing this with cobalt users so they can see the great integration between your two products using your API.

Anyway i guess the first step is just trying to get the api to work and the hopefully customize the code so it matches what we are doing in the other post.

Thanks!
Hello Gene,

What I gave in this forum is the general method on how to save and retrieve the custom field data and keyword $this should be used within the custom field file itself only. To actually used it outside the file, you must declare the class method for function getFieldData first. Try the following example,
$userId = JFactory::getApplication()->input->getInt('user_id'); // To retrieve the user id
$key = 'TEXTBOX-1'; // Custom field unique key
$my = FD::user($userId); // Method declaration
$fieldData = $my->getFieldData($key); // Get custom field data
echo $fieldData; // Echo the output
·
Wednesday, 15 July 2015 11:43
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Gene,

You need to put custom field unique key inside the $key area, for example,
$key = 'TEXTBOX-1';
$my->setFieldValue( $key , 'your saved value inside the textbox 1 that are actually being displayed on the frontend' );


Hope these help.
·
Thursday, 09 July 2015 14:53
·
0 Likes
·
0 Votes
·
0 Comments
·
Thanks I appreciate the response but what do you mean by this:
'your saved value inside the textbox 1 that are actually being displayed on the frontend'
·
Friday, 10 July 2015 21:55
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Gene,

I am sorry for the delay of this reply as it weekends for all of us here.

I am sorry for the confusion. What I mean is that for example you have created a new custom field called textbox-1 and you set it to be display during the registration or during the profile editing. The value or string that the user put during registration or during profile editing is the saved content inside the textbox-1 and it will be displaying on their profile frontend based on the setting set from the profile types.

You can refer to my screenshot here for a clearer view, http://screencast.com/t/5Anm0x9dPaM . Hope these help.
·
Monday, 13 July 2015 15:24
·
0 Likes
·
0 Votes
·
0 Comments
·
Sorry maybe I need to explain more as this is not working.
1. I created a custom field called "Academy'
2. I want the answer of that to be viewed on another page and use your api code for that. For example to display user name i do this:
<div><?php $userId = JFactory::getApplication()->input->getInt('user_id');
echo Foundry::user($userId)->getName();
?></div>


THIS WORKS FOR ME...


3. What do I replace
echo Foundry::user($userId)->getName();
WITH TO GET MY CUSTOM FIELD RESULT OF TEXTBOX-1.

Thanks!
·
Tuesday, 14 July 2015 02:53
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Gene,

Ah I see now what do you want to achieve here. Do you mean that you want to output the custom field value? If that so you can try the following API,
$textbox1 = $this->getFieldData('TEXTBOX-1');
echo $textbox1;
·
Tuesday, 14 July 2015 14:18
·
0 Likes
·
0 Votes
·
0 Comments
·
Unfortunately this is bad code: When i put this in:
<?php $userId = JFactory::getApplication()->input->getInt('user_id');
$textbox1 = $this->getFieldData('TEXTBOX-1');
echo $textbox1;
?>


Or even your raw suggestion:
<?php 
$textbox1 = $this->getFieldData('TEXTBOX-1');
echo $textbox1;
?>


I basically get the WSOD with just a little text:
http://www.awesomescreenshot.com/image/405212/5a57c7f2dfdadde834b16ae001faae7f
·
Tuesday, 14 July 2015 19:37
·
0 Likes
·
0 Votes
·
0 Comments
·
Please turn on error reporting and tell us the error message that you get
·
Wednesday, 15 July 2015 01:53
·
0 Likes
·
0 Votes
·
0 Comments
·
Notice: Undefined variable: id in /var/www/vhosts/t12sites.com/ua.t12sites.com/templates/g5_hydrogen/html/com_cobalt/records/default_user_block.php on line 17
Follow This User
Sara Bentley
Academy:
Fatal error: Call to undefined method CobaltViewRecords::getFieldData() in /var/www/vhosts/t12sites.com/ua.t12sites.com/templates/g5_hydrogen/html/com_cobalt/records/default_user_block.php on line 67
·
Wednesday, 15 July 2015 02:01
·
0 Likes
·
0 Votes
·
0 Comments
·
The data I'm trying to retrieve would follow after "Academy:"
·
Wednesday, 15 July 2015 02:01
·
0 Likes
·
0 Votes
·
0 Comments
·
You can't use the keyword $this in your own class. To be honest with you, these are more of a general php question and the method $this->getFieldData should only be used within the custom field file itself.
·
Wednesday, 15 July 2015 02:15
·
0 Likes
·
0 Votes
·
0 Comments
·
I appreciate your response but I only put in the code that was suggested to me within this forum.
<?php 
$textbox1 = $this->getFieldData('TEXTBOX-1');
echo $textbox1;
?>


And this code is causing the error. When I remove it.. .the error is gone and the page loads fine...

Thanks
·
Wednesday, 15 July 2015 02:47
·
0 Likes
·
0 Votes
·
0 Comments
·
This is the error I get when I put in the code that was suggested to me by support.
Fatal error: Call to undefined method CobaltViewRecords::getFieldData() in /var/www/vhosts/t12sites.com/ua.t12sites.com/templates/g5_hydrogen/html/com_cobalt/records/default_user_block.php on line 63
·
Wednesday, 15 July 2015 02:49
·
0 Likes
·
0 Votes
·
0 Comments
·
Hey Gene,

Please do take note that our support does not cover customizations / modifications request.
·
Wednesday, 15 July 2015 13:50
·
0 Likes
·
0 Votes
·
0 Comments
·
First of all THANKS. What you sent now works.
Second I apologize if it seemed I was trying to get custom work for free. That was not my intention at all. You have provided a great api document to embed other items on pages and I guess I was simply looking for the one that would work for custom fields as the one provided in the api document did not work.

Thank again for your great support!
·
Thursday, 16 July 2015 00:18
·
0 Likes
·
0 Votes
·
0 Comments
·
Thanks for updating, glad that your issues are resolved now
·
Thursday, 16 July 2015 00:36
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post