duplicate profile plugin

vandereyde 03 Feb, 2010
Hi there

I'm using the profile plugin to get data (email and name) from jos_users.
But I need some extra info from jos_comprofiler (eg cb_company) to load in the form when members want to register for an event.
Is it possible to get data from 2 tables by duplicating the profile plugin? Or another way?


GreyHead 03 Feb, 2010
Hi vandereyde,

The Profile Plugin is only designed to work with one table :-(

But you can hand-code a form to get pre-load data from any number of tables. You add the MySQL queries at the front and set the input values from the data.

vandereyde 03 Feb, 2010
thanks Bob.
But were exactly do I put the mysql queries? Is there a special field for this?
GreyHead 03 Feb, 2010
Hi vandereyde,

Add them inside <?php . . . ?> tags at the start of the Form HTML. You need to use some Joomla PHP code to set them up. There are many, many examples in the forums here if you search on 'query'

vandereyde 03 Feb, 2010
Great, thanks Bob. I'll do some searching.
vandereyde 04 Feb, 2010
Hi Bob
I did some searching and came up with a script I can use.
$user =& JFactory::getUser();

$q="SELECT cb_name
FROM jos_comprofiler
WHERE jos_comprofiler.user_id = '$id'";

while ($r2=mysql_fetch_array($r)) 

     echo "<h4>Your name is " .$r2[cb_name] ."</h4>";


This echos my cb_name field on top of the form. But now I want this field to be shown as a value in a formfield, like this:
<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Company</label>
    <input class="cf_inputbox" maxlength="150" size="30" title="" id="text_15" name="company" value="{cb_name}" type="text" />

But this way it doesn't show. Is there a way?

GreyHead 04 Feb, 2010
Hi vadereyde,

Please try value="<?php echo $r2['cb_name']; ?>"

And better to use the Joomla db code
if ( !$mainframe->isSite() ) { return; }
$user =& JFactory::getUser();
$db =& JFactory::getDBO();
$q = "SELECT `cb_name`
  FROM `#___comprofiler`
    WHERE `user_id` = ".$user->id."; ";
$r2 = $db->loadResult();
echo $r2['cb_name'];
I'm assuming this will be a unique result.

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