Forums

Populating Chrono Forms with Comm. Builder profile

brendo.cunningham 28 Jul, 2009
Hello,
I have found some discussions on this topic, but there does not seem to be a definitive answer. I am using CB 1.2.1 (downloaded today!)

I am hoping to allow some of my CB registered users to submit forms using the Chrono Forms component. However I want to make it an efficient task so I do not want them to keep entering their username, email address and other CB details that I have created. I had thought it a good idea to have hidden fields in the Chrono Form that would automatically populate with the CB details.

Has anybody achieved this? I am at a loss. It is relatively straightforward to populate Chronoforms fields using the standard Joomla registration table using the following method:

<?PHP  $user = JFactory::getUser(); ?>


However I require some custom fields from CB so using this method will not work.

If you have achieved this I would be very grateful if you could let me know your method.

Thanks.

Brendan
nml375 28 Jul, 2009
Hi Brendan,
In CB 1.2, this was pretty much straightforward, and unless the CB-team has changed their database table structures in 1.2.1, should work fairly well still.

<?
$user &= JFactory:getUser();
$db &= JFactory::getDBO();
$query = sprintf('SELECT * FROM %s WHERE %s = %i',
  $db->nameQuote('#__comprofiler'), /* Name of the database table, #__ will be replaced with the current
                                     * Joomla table prefix */
  $db->nameQuote('user_id'),        /* The field to search in the above table */
  $db->Quote($user->id)             /* The value to search for, in our case the user id from the user object */
);

$db->setQuery($query);
$result = $db->loadObject();        /* Perform the query and retrieve the result as an object. */
?>
<label for='custom_1'>My custom CB Field 1:</label><input name='custom_1' id='custom_1' value='<?
  if ($result)
    echo $result->custom_1;
?>' />

Written from memory, but should work..

/Fredrik
This topic is locked and no more replies can be posted.