Hello all,
On my website I have a simple contact form. In this form you fill in your name, email and the message.
If a guest want to use this form it has to fill in all these 3 things. I also have a member part on my website. If a member want to use the form I would like to see that it only has to fill in the message (his/her username and email will be in the username/email input boxes.
The last part I already got to work. I used the {cfu_email} and {cfu_username} to load the username and email in the form (and use readonly so it can't be edited).
Is it possible to make some kind "if else" thing? So I a guest uses the form (so not logged in)all the field will be empty and if a member uses the form only the message is empty and the name and email will be loaded with the user username and email.
Kind regards,
Ruud
On my website I have a simple contact form. In this form you fill in your name, email and the message.
If a guest want to use this form it has to fill in all these 3 things. I also have a member part on my website. If a member want to use the form I would like to see that it only has to fill in the message (his/her username and email will be in the username/email input boxes.
The last part I already got to work. I used the {cfu_email} and {cfu_username} to load the username and email in the form (and use readonly so it can't be edited).
Is it possible to make some kind "if else" thing? So I a guest uses the form (so not logged in)all the field will be empty and if a member uses the form only the message is empty and the name and email will be loaded with the user username and email.
Kind regards,
Ruud
Hi Ruud,
You could use two sets of form inputs in a Custom Element element and switch between them* using PHP to detect if the user is logged in or not.
Bob
* Later: when I actually wrote the sample code I used one set of inputs and switched the values and 'readonly' settings
You could use two sets of form inputs in a Custom Element element and switch between them* using PHP to detect if the user is logged in or not.
<?php
$user =& JFactory::getUser();
$name = '';
$email = '';
$readonly = '';
if ( $user->id > 0 ) {
$name = $user->name;
$email = $user->email;
$readonly = "readonly='readonly'";
}
?>
<div class="ccms_form_element cfdiv_text" id="name_container_div" style="">
<label for="name">Name</label>
<input id="name" maxlength="150" size="30" class="" title="" value=" <?php echo $name; ?> /" name="name" type="text" <?php echo $readonly; ?> />
<div class="clear"></div>
<div id="error-message-name"></div>
</div>
<div class="ccms_form_element cfdiv_text" id="email_container_div" style="">
<label for="email">Email</label>
<input id="email" maxlength="150" size="30" class="" title="" value=" <?php echo $email; ?> /" name="email" type="text" <?php echo $readonly; ?> />
<div class="clear"></div>
<div id="error-message-email"></div>
</div>Bob
* Later: when I actually wrote the sample code I used one set of inputs and switched the values and 'readonly' settings
This topic is locked and no more replies can be posted.
