Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

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

Hi,
I've made some custom user profile fields "phone" and "mobile" using the Joomla 2.5 profiles plugin.
Info on this is here.. 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 :)

Please Log in or Create an account to join the conversation.

Last edit: by organicwebs.

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

  • VeCrea
  • VeCrea's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
I already stated my interest in this, so i'll wait for that answer too

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.111 seconds

Real time saver and great Component Builder tool ! I have been developing with J-Cook Pro Component Builder for several months now and can say with all honesty that this product/service is second to none. The product is feature rich and is being improved and added to all the time. Do yourself a favor if you need to build a Joomla! Component then you can do no wrong in trying the product. You will save on time and effort while being able to deliver your project on time. J-Cook pro does the hard work for you you then have the freedom to fully customise the end result for your own needs. 

One word: Awesome.
Edwardcox (JED)
         

Get Started