:( ok, I have made my form connect to the juser database it appears and I can auto fill "some" fields but I need it to connect to the database with all of my community builder fields in it so I can autofill all of the fields that a user will have stored. So, after spending the last 8 hours on this I could really use some help to take it to the next level. All I need to know is how to make the form look up the data for the logged in user from the jos_comprofiler_fields table instead of the default joomla user table.
Here is the code (just part of the form but shows my syntax etc) - I can autofill the name but not the first name (which is firstname in the table I'm trying to call from). I even get the username to display properly "you are logged in as" I can get email but not a phone number... I am sure it's because my form is not looking up the data in the right place:
<?php
global $mainframe;
$database =& JFactory::getDBO();
$my = JFactory::getUser();
$query = "SELECT * FROM #jos_comprofiler_fields WHERE user_id = '".$my->id."'";
$database->setQuery( $query );
?>
<div>Your are logged in as <?php echo $my->username; ?>"</div>
<input type='hidden' name='jobid' value='' />
<input id="subject" name="subject" type="hidden"/>
<div class="form_item">
<div class="form_element cf_heading">
<h1 class="cf_text">Requester's Details</h1>
</div>
<div class="cfclear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label" style="width: 150px;">First Name*</label>
<input class="cf_inputbox required" maxlength="150" size="30" title="Please provide requester first name" id="text_1" name="rfname" value="<?php echo $my->name; ?>" type="text" />
<a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" alt="" src="components/com_chronocontact/css/images/tooltip.png"/></a>
<div class="tooltipdiv">First Name* :: Who can we contact with questions about this request?</div>
</div>
<div class="cfclear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label" style="width: 150px;">Last Name*</label>
<input class="cf_inputbox required" maxlength="150" size="30" title="Please provide requester last name" id="text_2" name="rlname" value="<?php echo $my->lastname; ?>" type="text" />
<a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" alt="" src="components/com_chronocontact/css/images/tooltip.png"/></a>
<div class="tooltipdiv">Last Name* :: Who may we contact with questions about this request?</div>
</div>
<div class="cfclear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label" style="width: 150px;">Company or Organization*</label>
<input class="cf_inputbox required" maxlength="150" size="30" title="Please provide the requester company or organization name. If an individual just type individual" id="text_3" name="rcompany" value="<?php echo $my->company; ?>" type="text" />
<a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" alt="" src="components/com_chronocontact/css/images/tooltip.png"/></a>
<div class="tooltipdiv">Company or Organization* :: Please provide the requester company or organization name. If an individual just type individua</div>
</div>
<div class="cfclear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label" style="width: 150px;">Email*</label>
<input class="cf_inputbox required validate-email" maxlength="150" size="30" title="Please provide the requester email" id="text_4" name="remail" value="<?php echo $my->email; ?>" type="text" />
<a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" alt="" src="components/com_chronocontact/css/images/tooltip.png"/></a>
<div class="tooltipdiv">Email* :: Please provide an email address to confirm we recieved this request and contact the requester with any questions.</div>
</div>
<div class="cfclear"> </div>
</div>
Hi sitebuildernow ,
Thanks for posting this - I'm sure it will be useful. Neither Max or I is a CB user so we find these requests difficult to answer.
There is very little in your code that I would do differently, mostly cosmetic stuff.
Bob
PS it's the FROM #__comprofiler that identifies the table - you could have used anything in place of $cb, $xxyyz would work.
HI guys,
Great topic. I am trying to do the same thing and this code seems to work great on pulling out the field date from the jml_users table. However, when I try to use it on the jml_comprofiler table and attach it to a field in that table it does not work?
Any thoughts?
Hi fkaram65 - I "think" you need to leave off the jml part - only put in the _comprofiler part... but I'm only a hacker and not a programmer at all!
Harmony
Hi fkaram65,
The jml_ prefix is probably needed but because prefixes vary I use the Joomla! default prefix of #__ in examples here. Joomla! will replace that with the specific prefix for your site.
My memory is that CB uses a complex table sturcture for some fields. You probably need to test the MySQL using PHPMy Admin to make sure that it works correctly.
Bob