Forums

How to automatically fill out fields for registrated users

reha 19 Aug, 2011
Hello Forum, hello Bob,

i got some problems getting the joomla users filled in some of my text boxes for registrated users.
Before i've switched to ChronoForms, i've used Breezingforms where it was easy getting the informationen i wantend.

I've read the tutorials but i cant get it to work.😟

Here my problem in screenshots:

1. The Problem


2. I want to use the joomla "_users"-table to get the data to work.


3. Thats how it should be


4. What i've inserted in the DB Record Loader "on record found" jet (doesnt work)


5. Here's the full code of my form.
<div class="ccms_form_element cfdiv_textarea" id="nachricht_container_div"><textarea cols="72" rows="10" class=" validate['required']" title="" type="textarea" name="nachricht"></textarea>
<div class="clear"></div><div id="error-message-nachricht"></div></div><div class="ccms_form_element cfdiv_custom" id="input_custom_2_container_div">Adressangaben

Bitte geben Sie hier Ihre Adressdaten ein, damit wir Sie für eine Rückantwort kontaktieren können.<div class="clear"></div><div id="error-message-input_custom_2"></div></div><div class="ccms_form_element cfdiv_text" id="name_container_div"><label>Name</label><input maxlength="150" size="30" class=" validate['required']" title="" type="text" value="" name="name" />
<div class="clear"></div><div id="error-message-name"></div></div><div class="ccms_form_element cfdiv_text" id="benutzername__container_div"><label>Benutzername:</label><input maxlength="150" size="30" class="" title="" type="text" value="" name="benutzername" />
<div class="clear"></div><div id="error-message-benutzername"></div></div><div class="ccms_form_element cfdiv_text" id="e_mail__container_div"><label>E-Mail:</label><input maxlength="150" size="30" class=" validate['required','email']" title="" type="text" value="" name="email" />
<div class="clear"></div><div id="error-message-email"></div></div><div class="ccms_form_element cfdiv_custom" id="input_custom_6_container_div">Ihre persönlichen Daten werden vertraulich behandelt und nicht an Dritte weitergegeben.<div class="clear"></div><div id="error-message-input_custom_6"></div></div><div class="ccms_form_element cfdiv_submit" id="abschicken_container_div"><input name="abschicken" class="" value="Abschicken" type="submit" />
<div class="clear"></div><div id="error-message-abschicken"></div></div>



I dont know if it helps you. In Breezingforms i have used following php-code in the textbox-code-editor of the field (for example "name") which has worked for me.
<?php
global $user;
$user =& JFactory::getUser();
$userid = $user->id ;
if ($userid > 0)
return JFactory::getUser()->get('name');
else
return ('Bitte als Benutzer einloggen');
?>



Looking forward to your great reply(s).🙂

Thanks

David
gabedaly 20 Aug, 2011
Try placing this code in the Where box of the DB record loader. It pulls the info for the logged in user.

<?php
$user = &JFactory::getUser();
echo "id = ".$user->id
?>
GreyHead 20 Aug, 2011
Hi reha,

A slightly different approach.

Instead of using the DB Record Loader go to the Preview tab and drag in a Custom Element to your form. Open the configuration dialogue; check the Pure code box to hide the element; then put this in the Code box:
<?php
$user = JFactory::getUser();
?>

Then open the configuration dialogues for the text inputs and put code into the Value boxes:
<?php echo $user->name; ?>

<?php echo $user->email; ?>

<?php echo $user->username; ?>
etc.

Bob
reha 30 Aug, 2011
Hi Bob, hi gabedaly,

thanks for your answers.
I used Bob answer, but in my E-Mail-field i got some errors like: " <script type='text/javascript'> <!-- var prefix = ...."

I'm using the Joomla Beez_20 Template.

I found a solution. Add follwing code in the E-Mail-Field like Bob's solution.

<?php echo $user->email;?>{emailcloak=off}
GreyHead 30 Aug, 2011
Hi reha,

You have the Joomla! Email Cloaking Plug-in enabled and it is trying to cloak the sample e-mail in the ChronoForms validation message. Disable the plug-in temporarily to check this is the problem. If you need the plug-in change the plug-ins order so that Email Cloaking runs before ChronoForms.

NB These are Joomla! plug-ins that you manage from Site Admin | Extensions | Plug-in Manager

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