Welcome, Guest
Username: Password: Remember me

TOPIC: Reading and Saving User Profiles #__user_profiles

Reading and Saving User Profiles #__user_profiles 15 May 2013 11:32 #7192

  • organicwebs
  • organicwebs's Avatar
  • Offline
  • Premium Member
  • Chris
  • Posts: 133
  • Thank you received: 21
  • Karma: 4
Hi,
I've made some custom user profile fields "phone" and "mobile" using the Joomla 2.5 profiles plugin.
Info on this is here.. http://docs.joomla.org/Creating_a_profile_plugin

After playing with the model prepareQuery (com_mycomponent/models/myform.php ) - I can read the user profile data - but I cannot save it back into #__user_profiles. Its the nature of the SQL query I've written - it defaults back to saving the profile data into my dummy JCook table instead of #__user_profiles.

You see, the #__user_profiles table does not have a column for every field type. Instead its a simple 4 column table that stores the user_id, profile_key, profile_value and order.

My customised code...
protected function prepareQuery(&$query, $pk)
	{
....
	//SELECT - added fields from the user profile table
	$this->addSelect('_user_profiles_phone_.profile_value AS phone');	
	$this->addSelect('_user_profiles_mobile_.profile_value AS mobile');
...
	//JOIN - join the user profile table
	$this->addJoin('`#__user_profiles` AS _user_profiles_phone_ ON _user_profiles_phone_.user_id = a.joomla_user AND _user_profiles_phone_.profile_key = "profile.phone"', 'LEFT');
	$this->addJoin('`#__user_profiles` AS _user_profiles_mobile_ ON _user_profiles_mobile_.user_id = a.joomla_user AND _user_profiles_mobile_.profile_key = "profile.mobile"', 'LEFT'); 

Has anyone used the prepareQuery SQL to write back to #__user_profile? If so - what SQL statements did you use?

As a workaround I'm manually saving the user_profile data in the model's public function save($data).
Just call me Chris :)
Last Edit: 15 May 2013 11:43 by organicwebs.
The administrator has disabled public write access.

Re: Reading and Saving User Profiles #__user_profiles 16 May 2013 18:22 #7197

  • VeCrea
  • VeCrea's Avatar
  • Offline
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
  • Karma: 30
I already stated my interest in this, so i'll wait for that answer too
The administrator has disabled public write access.
Time to create page: 0.075 seconds

Get Started