Putting Joomla user info automatic in form.

  • Posts: 2780
  • Karma: 95
  • Thank you received: 375

mihaela replied the topic: Putting Joomla user info automatic in form.

Hello,

If you want to fetch mobile number and country that user enters in Joomla registration form, then please take a look at this topic crosstec.org/en/forums/35-form-help/1248...ile-data.html#229656 since here your question is answered.

For example, to prefill a field with the user's phone number put this as value:
<?php $profile = JUserHelper::getProfile($user->id);return $profile->profile;?>

If you want to fetch value from some other database table then navigate to form's Advanced properties > More options > Form pieces and in Before Form section set Type to Custom.

In the code area below put code similar to this one:
$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db = JFactory::getDBO();//Get Database Object

$db->setQuery("SELECT ... "); 
$result = $db->loadResult();

ff_setValue('fieldname', $result);
You have to put the correct query in setQuery() and replace fieldname with the name of the field that you wish to fill in with value from database.

Let me know whether you have managed to make this work as you wanted.

Regards,

Mihaela
#235529
  • Posts: 84
  • Thank you received: 1

geeksscript replied the topic: Putting Joomla user info automatic in form.

Hi Mihaela,

I tried doing below but wasn't able to make it work:
$this->execPieceByName('ff_InitLib');
$user = JFactory::getUser();
$userId = $user->id; 

$db1 = JFactory::getDBO();
$db1->setQuery("SELECT mobile FROM jkk_user WHERE user_id = $userId");
$phone = $db1->loadResult();

$db2 = JFactory::getDBO();
$db2->setQuery("SELECT location_id FROM jkk_user WHERE user_id = $userId");
$locationId = $db2->loadResult();

ff_setValue('ff_elem2836', $phone);
ff_setValue('ff_elem2837', $locationId);

Please guide.
#235651
  • Posts: 2780
  • Karma: 95
  • Thank you received: 375

mihaela replied the topic: Putting Joomla user info automatic in form.

Hello again,

Please try to use the following code instead of the one you are using now:
$this->execPieceByName('ff_InitLib');
$user = JFactory::getUser();
$userId = $user->id; 

$db1 = JFactory::getDBO();
$db1->setQuery("SELECT mobile FROM jkk_user WHERE user_id = '$userId' ");
$phone = $db1->loadResult();

$db2 = JFactory::getDBO();
$db2->setQuery("SELECT location_id FROM jkk_user WHERE user_id = '$userId' ");
$locationId = $db2->loadResult();

ff_setValue('ff_elem2836', $phone);
ff_setValue('ff_elem2837', $locationId);

Regards,

Mihaela
#235681
  • Posts: 84
  • Thank you received: 1

geeksscript replied the topic: Putting Joomla user info automatic in form.

Mihaela, this still is not working. I even tried mentioning the user id directly but no luck. Please guide.
#235682
  • Posts: 84
  • Thank you received: 1

geeksscript replied the topic: Putting Joomla user info automatic in form.

Hello Mihaela, just wanted to check if there is any update on my previous reply(?)
#235761
  • Posts: 2780
  • Karma: 95
  • Thank you received: 375

mihaela replied the topic: Putting Joomla user info automatic in form.

Hello,

Somehow I've missed your previous post.

I will ask just to check whether we've understood each other correctly.

You have created a custom table named "jkk_user" in Joomla database. In that table columns "user_id", "mobile" and "location_id" are present. Furthermore, when you test this you are logged in with a user account whose ID is in "jkk_user" table. Is all that correct?

Regards,

Mihaela
#235763
Moderators: ForumSupporttomeperica
Time to create page: 0.072 seconds

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans, templates and icon packs!

Get Your Subscription Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99 for just 49! (Summer Sale)

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here