Forums

How use CB plugins? Need CB infos to send in admin emails

studiometeor 25 Jan, 2010
Hello,
Sorry, may be this question have already been answered, but I could'nt find in this forum, or may be the question seems to be to easy... (or not so english as I'm french^^)
I publish a form on my website, that only registred people can access,
I'd like to have the infos from the CB user inside the email that will be sent to the administrator, but just don't know how to do this.
I've try some things with the {cb_name} and using the CB registration plugin, but just could find how to make it work....
thanks
GreyHead 25 Jan, 2010
Hi studiometeor,

I'm sure it's possible - you'd need to get the info from the CB database tables with a MySQL query. But I don't know exactly what you'd need to have in the query.

Bob
studiometeor 25 Jan, 2010
Ok, so the CB registration plugin is not that for.
I'll try with Mysql queries and tell here how it works.
thanks
GreyHead 25 Jan, 2010
Hi studimeteor,

The CB Regsitration plugin is for registering members in CB - but as far as I know it doesn't work correctly with the latest release of CB.

Bob
studiometeor 27 Jan, 2010
Hi again,

for email and name/login it is ok with:
<?php $val = $_GET['user'];?>
<?php $user = &JFactory::getUser($val); ?>
<?php if ($user->id > 0) echo $user->email ; ?>


I now try to have the others CB fields. I've try with:



$user =& JFactory::getUser();  
$sds_user_id = $user->id; 
$query = "SELECT `cb_structure` FROM `jos_comprofiler` WHERE `user_id` = ({$sds_user_id})"; 
$database->setQuery($query); 
$sds_structure = $database->loadResult(); 


echo $sds_structure ;


but it don't works....
may be I'd better ask the question on Joomlapolis...
GreyHead 28 Jan, 2010
Hi studiometeor,

Asking in the CB forum could well be useful.

I'd echo out your query and check that it works by copying and pasting directly into PHPMyAdmin.

Bob
rmesman 12 Apr, 2010
Hi Studiometeor,

I've used this code as the start in my form:

<?php
$user =& JFactory::getUser();
$db =& JFactory::getDBO();
$query = "SELECT * FROM `jos_comprofiler` WHERE `id` = ".$user->id."; ";
$db->setQuery($query);
$user_info = $db->loadObject();
?>


$user_info is an array which contains all info for that user from the 'jos_comprofiler' table .
For example:
User 'John Shoe' logs in and you want to start your form with "Dear John Shoe,". You can put in your form:
Dear <?php echo $user_info->firstname; ?> <?php echo $user_info->lastname; ?>,


Example 2:
You would like to automatically fill a form-field with the CB-firstname of that user:

<input name="firstnaam" type="text" id="firstname" size="75" maxlength="150" VALUE="<?php echo $user_info->firstname; ?>">


You have to check the jos_comprofiler table to see which field are available. Hope this helps.

~Robin
SPABO 12 Apr, 2010
Hey....this is what I was looking for😀

After a long survey...here is the answer, but still a sall question

I also want to include the emailaddress, which in CB is defined as "primaryemailaddress", which I need for returning an email to the member on submit

I have now put in
<input name="email" type="text" id="email" size="30" maxlength="150" VALUE="<?php echo $user_info->email; ?>">


But the emailadress does not appear....
Any ideas?
rmesman 12 Apr, 2010
Hi SPABO,

There is no such field as 'email' in de 'jos_comprofiler' table. The email is stored in the 'jos_users' table.

You can use the following code:
<input name="email" type="text" id="email" size="30" maxlength="150" VALUE="<?php echo $user->email; ?>">


Does this work?

~Robin
SPABO 03 May, 2010
Everything is working fine now, the form shows now data from CB (after the user has logged in)
I have this in the code (in the beginning)
<?php
$user =& JFactory::getUser();
$db =& JFactory::getDBO();
$query = "SELECT * FROM `jos_comprofiler` WHERE `id` = ".$user->id."; ";
$db->setQuery($query);
$user_info = $db->loadObject();
?>


Ans this as an example for Lastname
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label" style="width: 150px;">Achternaam</label>
<input name="lastname" type="text" id="lastname" size="30" maxlength="150" VALUE="<?php echo $user_info->lastname; ?>">  </div>
<div class="cfclear"> </div>
</div>


But....the user can overwrite this field...
Is there a way to make this field not writeable??
GreyHead 06 May, 2010
Hi SPABO,

You can make the input 'Readonly'; or to make it look prettier you can just out put the value there and have a hidden input to make sure that it is saved correctly.
<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Achternaam</label>
    <?=$user_info->lastname?>">
  </div>
  <div class="cfclear"> </div>
</div>
<input name="lastname" type="hidden" id="lastname" value="<?=$user_info->lastname?>">

Bob
SPABO 07 May, 2010
Hi Bob
Sorry for my late reply on thsi, what you are proposing does not "show"the field in the from.

Pls find a code to have it disabled AND hiden, in this way the field is visible, but can not be overwritten (of course in combination with teh cde to run the DB
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label" style="width: 150px;">Voornaam</label>
<input type="text" id="firstname" size="30" maxlength="150" value="<?php echo $user_info->firstname; ?>" disabled="disabled" />
<input name="firstname" type="hidden" value="<?php echo $user_info->firstname; ?>" />
<div class="cfclear"> </div>
</div>


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