How to reference custom field with PHP?
- iananderson
- Topic Author
- Offline
- New Member
Less
More
- Thank you received: 0
10 years 9 months ago #7270
by iananderson
Hi,
I have a custom field for Company Name in my user profile. I want to display this Company Name in a table using something like:
<td>
<?php $user = JFactory::getUser($item->created_by); //echo $user->ajax_custom_field->15; ?>
</td>
What is the correct code for ajax_custom_field->15 ?
Thanks
Ian
I have a custom field for Company Name in my user profile. I want to display this Company Name in a table using something like:
<td>
<?php $user = JFactory::getUser($item->created_by); //echo $user->ajax_custom_field->15; ?>
</td>
What is the correct code for ajax_custom_field->15 ?
Thanks
Ian
Please Log in or Create an account to join the conversation.
- Saka
- Offline
- Administrator
- giosto
- Offline
- New Member
Less
More
- Thank you received: 0
10 years 9 months ago #7272
by giosto
Unfortunately, I found a serious error to the component!
When I want to access extra fields from a user that is NOT the current one, do not get any extra field.
I checked and all the other normal fields (not extra) are correctly valued.
for example:
1) require the current user: $utente =& JFactory :: getUser ();
There are all my extra fields (example: $utente-> extra is ok)
2) I wonder if the data of another user (by id): $utente = JFactory :: getUser (639);
all the normal fields (example: username, email, etc..) there are, and all the extra fields are NOT valued!
For my needs this is a very serious problem.
Giovanni
When I want to access extra fields from a user that is NOT the current one, do not get any extra field.
I checked and all the other normal fields (not extra) are correctly valued.
for example:
1) require the current user: $utente =& JFactory :: getUser ();
There are all my extra fields (example: $utente-> extra is ok)
2) I wonder if the data of another user (by id): $utente = JFactory :: getUser (639);
all the normal fields (example: username, email, etc..) there are, and all the extra fields are NOT valued!
For my needs this is a very serious problem.
Giovanni
Please Log in or Create an account to join the conversation.
- iananderson
- Topic Author
- Offline
- New Member
Less
More
- Thank you received: 0
10 years 9 months ago #7273
by iananderson
But when I follow the instructions I get mixed results.
I am using the code:
<td>
<?php $user = JFactory::getUser($item->created_by); echo $user->extra; ?>
</td>
But it only works when the Super Admin is logged in. For a public user or registered user, the table is blank.
Any help?
Thanks
Thanks for this info.www.sakic.net/forum/ajax-series/using-in...ter/msg7459/#msg7459
But when I follow the instructions I get mixed results.
I am using the code:
<td>
<?php $user = JFactory::getUser($item->created_by); echo $user->extra; ?>
</td>
But it only works when the Super Admin is logged in. For a public user or registered user, the table is blank.
Any help?
Thanks
Please Log in or Create an account to join the conversation.
- Saka
- Offline
- Administrator
10 years 9 months ago #7275
by Saka
Emir Sakic
www.sakic.net
AJAX Register automatically attaches the extra info only to the current user.
If you want to get extra info for other users you can do something like this:
If you want to get extra info for other users you can do something like this:
$user = JFactory::getUser($userid);
plgSystemAJAXRegister::attachExtraFields($user);
print_r($user->extra);
Emir Sakic
www.sakic.net
Please Log in or Create an account to join the conversation.
- giosto
- Offline
- New Member
Less
More
- Thank you received: 0
10 years 9 months ago #7276
by giosto
Very good!
Now it works.
Perhaps it is important to write the documentation for the component.
Thank you.
Now it works.
Perhaps it is important to write the documentation for the component.
Thank you.
Please Log in or Create an account to join the conversation.