Putting Joomla user info automatic in form.

  • kingo-tech
  • kingo-tech's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 48
  • Thank you received: 0

kingo-tech created the topic: Putting Joomla user info automatic in form.

Hi

Is it possible in any way to get a users info into the formfield if the user is logged in.

I have found out to get the users name and email into the form, by putting following into the Value field, in the text field.

Name = <?php return JFactory::getUser()->get('name',''); ?>
E-Mail = <?php return JFactory::getUser()->get('email'); ?>

But what if i want address1, zip code, city, phonenumber ?
#229565
  • Posts: 2154
  • Karma: 67
  • Thank you received: 263

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

Hey,

you're going to have to approach it a bit differently for profile info as JFactory::getUser gets only data regarding the backend for user, such as if he's logged in, username, password, etc.

To get addresses, city etc, you have to use:
- option 1: in Before Form:
$this->execPieceByName('ff_InitLib');
$user = JFactory::getUser();
$userId = $user->id; 
$userProfile = JUserHelper::getProfile( $userId );

ff_setValue('name-of-field', $userProfile->profile['address1']);

-option 2: one-liner to use in Value field:
<?php $userProfile = JUserHelper::getProfile(JFactory::getUser()->id); return $userProfile->profile['address1']; ?>

If you want to check all the fields available in $userProfile, simply do the following in the Before Form piece:
$userProfile = JUserHelper::getProfile(JFactory::getUser()->id); echo '<pre>'; print_r($userProfile); echo '</pre>'; Let me know if you need assistance. Kind regards, Darko[code]$userProfile = JUserHelper::getProfile(JFactory::getUser()->id);
echo '<pre>';
print_r($userProfile);
echo '</pre>';

Let me know if you need assistance.

Kind regards,
Darko

Satisfied with our support? PayPal tips
===========
Need to renew Pro Support? Buy Here!
===========
Satisfied? Consider a membership!
===========
Like us on Facebook
===========
Support Crosstec and get ALL EXTENSIONS and professional support for just $5. Here!
#229573
  • Posts: 52
  • Thank you received: 1

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

Hello,

How can I fetch value from a custom table?
#235167
  • Posts: 52
  • Thank you received: 1

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

Hello Darko! Please help me with fetching value from a custom table.
#235518
  • Posts: 2109
  • Karma: 72
  • Thank you received: 268

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

Hello,

Darko no longer works on support.

Please explain a bit more, what kind of custom table do you have? Is it user related or it is just a table that you have in your database that contains data you wish to fetch?

Regards,

Mihaela
#235521
  • Posts: 52
  • Thank you received: 1

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

Sure Mihaela!

It is just a table that I have in my database which contains mobile number and country. I wish to fetch these 2 details.
#235524
Moderators: ForumSupporttomeperica
Time to create page: 0.042 seconds

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

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€

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!

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