Forums

Retrieve Community Builder data in form based on login

rmesman 02 Feb, 2012
Hi,

I'm working with J1.7/CFv4. I want to publish a form where information from the Community Builder DB is being displayed based on who is logged in.
I want to use DB Record Loader (DBRL) to load the data. I have setup the DBRL to load all data from the CB table (jos_comprofiler) and put the data in a Model (CBUser) to use in the form. To load only the data for the user who is logged in I use the following code at the WHERE statement:
user_id = "<?php JFactory::getUser()->id; ?>" 


To test the form if the correct data will be displayed, at the "On record found" part, I've put a custom code:
<?php $details = $form->data['CBUser'];?>
Your CB-ID: <?php <?php echo $details['user_id']; ?>


To display if nothing is found I use the custom code "On empty Result":
<p>No user found.</p>

And have put the 'stopper'-part

When I log in to the website and run the form nothing is displayed. I think I have done something wrong at the WHERE statement.

Who has some notes how to solve this. Thanks :-)
Robin
rmesman 02 Feb, 2012
I've found that the code for diplaying the user_Id contains a double <?php. This should be the correct code:

<?php $details = $form->data['CBUser'];?>
Your CB-ID: <?php echo $details['user_id']; ?>


But this doesn't solve the problem :-(

If I put the custom code block for displaying the data áfter the DBRL block (not in "On Record Found" part ín the DBRL) then "Your CB-ID" is being displayed!. But not with teh user_id ...

Robin
GreyHead 03 Feb, 2012
Hi rmesman,

The line in the WHERE box needs an echo and I'm not sure you can use that syntax, please try:
<?php
$user =& JFactory::getUser();
echo " `user_id` = '{$user->id}' ";
?>

Bob
rmesman 08 Feb, 2012
Hi Bob,

I've tried it but it doesn't work. I've came up with another solution by using only custom code, also to output the html.

Thanks anyway.

Regards,
Robin
SPABO 17 Feb, 2012
Pls can you share this, as I'm struggling as well
Do also keep the data of teh submeiited form in a chronoforms db?
SPABO 24 Feb, 2012
Topic can be cloed, my "problem" has been solved
This topic is locked and no more replies can be posted.