• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: How to: Load user com_fields in form from DB

How to: Load user com_fields in form from DB 7 years 7 months ago #37409

  • addons
  • addons's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
To help others.

I've been looking how to load the optional fields that can be used for logged in users in Joomla 3.7.x.

Case: Added Gender and Region in com_fields option

Gender will become "field_id" 1, Region "field_id" 2 and so on.

Just change FROM `josy4_fields_values` into your own prefix (josy4)
And then change `field_id`=2" into the right id for this RSForms field.
//<code>
$user   = JFactory::getUser();
$db   = JFactory::getDbo();
$userId  = $user->get('id'); 
 
// Is the user logged in?
if ($userId) {
  // Grab the value from the database.
    $db->setQuery("SELECT `value` FROM `josy4_fields_values` WHERE `item_id`='".$userId."' AND `field_id`=2");
    return $db->loadResult();
}
//</code>

When the form is loaded, the information in the com_fields added will be added.
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!