Field values from Easy Profile component - how?

  • Zotius
  • Zotius's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 14
  • Thank you received: 0

Zotius created the topic: Field values from Easy Profile component - how?

Hello Professionals!
I'm still a beginner in BF programming, help me:
I use the Easy Profile component for creating and use custom profile fields.
What the maker describes on his website where and how must to insert in BF form?
require_once(JPATH_SITE.'/components/com_jsn/helpers/helper.php');
$user=new JsnUser(<id_of_user>);
He wrote there: Retrieve Raw User Field
$user=new JsnUser(<id_of_user>);
echo $user->getValue(<field_alias>);
Example: I want to populate value from my custom field (alias name serial-number) to the textfield form element.

Regards,
Zotius
#110722
The topic has been locked.
  • Posts: 4667
  • Karma: 72
  • Thank you received: 411

lennerd replied the topic: Field values from Easy Profile component - how?

Hello,

please try it like this:

1. Open your form and go to Form properties->advanced->more options->form pieces-> before form-> custom

2. then try this code:

$this->execPieceByName('ff_initLib');

require_once(JPATH_SITE.'/components/com_jsn/helpers/helper.php');

$userid=JFactory::getUser->get("id");

$user=new JsnUser($userid);

$fieldvalue= $user->getValue(<field_alias>); // provide fied alias

ff_setValue('NameOfFormelement') ; // change to the name of the element you want to fill


Please not this is not tested because we do not know this easy profile component, but it should work.

Regards,
Stefan

===============================================
Satisfied? Consider a membership!
===============================================
Like us on Facebook
===============================================
Follow us on Twitter
===============================================
#110858
The topic has been locked.
  • Zotius
  • Zotius's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 14
  • Thank you received: 0

Zotius replied the topic: Field values from Easy Profile component - how?

Thank you for your answer. Sorry, don't work. But the problem maybe not so big as we think. The component 'Easy Profile' have two tables. The first (name: #_jsn_fields) contain specifications of the fields, (ex. type, lenght, etc.) and the second table (name: #_jsn_users) contain the field values (one row = one user).
When I create a new field, the component create a new column in these table named "#_jsn_users", where the first column is "id", which represent the ID of user, and this equal with $userid in #_users.
So I think that with a simple SQL query possible read value from this table, without using the "require_once ..." command.
$this->execPieceByName('ff_initLib');
$userid=JFactory::getUser->get("id");
$sql = "SELECT <myfielname> FROM #_jsn_users WHERE id=`".$userid."`";  //  #_jsn_users contain exact tablename
$fieldvalue = ff_selectValue($sql);
ff_setValue('<myfieldname>');  // myfieldname contain exact field (column) name
But something wrong in this code, because it's not work - I don't know why.

Regards,
Zotius
#110882
The topic has been locked.
  • Zotius
  • Zotius's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 14
  • Thank you received: 0

Zotius replied the topic: I don't understand...

What is the real name of my field on the form?
On the BF admin screen I set fieldname to 'tavhofsid' and the frontend view with Web developer (in Firefox), there I see this:
<input id="ff_elem173" class="ff_elem" type="text" value="" name="ff_nm_tavhofsid[]" maxlength="13" style="width:100px" placeholder="identifier"></input>
tavhofsid <> ff_nm_tavhofsid
In Form properties->advanced->more options->form pieces-> before form-> custom I try this script:
$this->execPieceByName('ff_initLib');
$userid = JFactory::getUser->get('id',0);
require_once(JPATH_SITE.'/components/com_jsn/helpers/helper.php');
$user = new JsnUser($userid);
$fieldvalue = getValue(tavhofsid);
ff_setValue('tavhofsid');

Regards,
Zotius
#110933
The topic has been locked.
  • Posts: 6982
  • Karma: 187
  • Thank you received: 628

chrisal replied the topic: I don't understand...

Hello Zotius,

tavhofsid is correct.

Please use this code instead:
$this->execPieceByName('ff_initLib');
$user =& JFactory::getUser();
$sql = "SELECT <myfielname> FROM #_jsn_users WHERE id=`".$user->get('id')."`";  //  #_jsn_users contain exact tablename
$fieldvalue = ff_selectValue($sql);
ff_setValue('tavhofsid');  // myfieldname contain exact field (column) name

Let us know if you have further questions.

regards
Chris

Regards,
Christian

===============================================
Satisfied? Consider a membership!
===============================================
Like us on Facebook
===============================================
Follow us on Twitter
===============================================
#111134
The topic has been locked.
  • Zotius
  • Zotius's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 14
  • Thank you received: 0

Zotius replied the topic: This was the correct solution

This was the correct solution: To the 'Value' field I wrote this code:

<?php $id = JFactory::getUser()->get('id',0); $sql = "SELECT tavhofsid FROM #__jsn_users WHERE (id = '".$id."')"; $rows = ff_select($sql); $record = $rows[0]; $field = $record->tavhofsid; return $field; ?>

It works! :)
The only little problem was, that difficult edit the long code in textfield.

Regards,
Zotius
#111651
The topic has been locked.
Moderators: ForumSupporttomeperica
Time to create page: 0.069 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