Get Current User's profile values for Fabrik form?

fabrikg09

Member
Is there a way of referring to the ALL of the variables containing the values of the current user's profile into a Fabrik element of the field type?

I wrote a custom user profile that adds entries for Company and Full Name, and I want to pull these values onto a Fabrik form. Sort of performing the same function as an autofill. (The autofill feature seems difficult/impossible to grasp, at least to me...)

I've been able to get SOME of the values by putting, for instance, this into the Options/Eval box:

$user =& JFactory::getUser();
$email = $user->get('email');
return $email;
//that works fine//

$user =& JFactory::getUser();
$username = $user->get('username');
return $username;
//also works fine//

But if I try this, which refers to one of the standard profile items, phone:

$user =& JFactory::getUser();
$phone = $user->get('phone');
return $phone;

It returns nothing. Are not all of the entries in the user's profile contained in the session values? If so, how does one call them?
 
"Phone" is no Joomla user profile item.

For the other ones: it depends what you want to do:
-pull existing values (the user can modify, modification only in your own profile list): autofill or the way you mentioned
-Keep your profile entries synchronized with the Joomla user entries: add form plugin jUser
- display Joomla profile values: user element or dbjoin element to #_users
 
This is apparently the problem - what exactly are the user profile variables that can be accessed?

I think I will have to pull the info by using PHP and going directly to the table in question. I just want to autofill Name and Company (two of my custom profile fields) on to my Fabrik form, so that:

1.)The user doesn't have to do this
2.) When the email is sent, it contains Name and Company, which for a large number of users, is more convenient than seeing the username or id.
 
Hi fabrikg09

Have you managed to find a solution to add Company into the user profile? I need to create a pre-filter for a list which can use the fabrik user plugin to filter the data by company.

Thanks
 
Yes - I originally did that by creating a custom user profile, adding the fields that I needed. Once the new fields have been added, it is easy to bring them into a Fabrik form element. My custom profile is called "profile10" here:

$db =& JFactory::getDBO();
$query = "SELECT SUBSTR(`profile_value`,2,LENGTH(`profile_value`)-2) AS `profile_value` FROM `mysite_user_profiles` WHERE `user_id` = '{$my->id}' AND `profile_key` = 'profile10.company'";
$db->setQuery($query);
$cname = $db->loadResult();
return $cname;

I couldn't have figured this out without the excellent support I received from the Fabrik developers here! HTH

NB: There are a lot of good references online to explain the details of creating a custom user profile. Just Google the problem.
 
Hi
Sorry for bumping this old thread up but it may help me or someone .

I successfully mad a profile plugin and used this code to show custom profile information but there is problem with unicode characters, they are saved and displayed as json encoded : i.e.: \u0435\u0442\u0430\u0436

$db =& JFactory::getDBO();
$query = "SELECT SUBSTR(`profile_value`,2,LENGTH(`profile_value`)-2) AS `profile_value` FROM `mysite_user_profiles` WHERE `user_id` = '{$my->id}' AND `profile_key` = 'profile10.company'";
$db->setQuery($query);
$cname = $db->loadResult();
return $cname;​


I tried something like:
$cname1 = json_decode($cname)
return $cname;​
it shows a blank result
How may I decode them?

Any help would be greatly appreciated
 
That's not actually JSON encoded, that's unicode. Although one convenient way of decoding it is to run it through json_decode. However, you'd have to wrap double quotes round it, to make it a valid JSON string, like ...

Code:
$cname = json_decode('"' . $cname . '"');

Although I suspect the root of the problem may be your table's character set and collation. Setting it to something like charset utf8 and collation of utf8_general_ci might cure the problem.

-- hugh
 
THANK you very much,

Yes, the first thing I did, was to change and correct the collation to : utf8_unicode_ci and your code made it to work.

I really appreciate your great job
Regards
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top