Hi All
I am trying to get my forms to which are only accessible to logged user to auto fill their name and emails I tried this bit I found on the forums but it seems to break my form and only display a blank page any help would be greatly appreciated.
I am trying to get my forms to which are only accessible to logged user to auto fill their name and emails I tried this bit I found on the forums but it seems to break my form and only display a blank page any help would be greatly appreciated.
<?php
global $my, $database;
$query = "SELECT *"
. "\n FROM #jos_contact_details"
. "\n WHERE user_id = '$my->id'";
$database->setQuery( $query );
$contact = $database->loadObjectList();
$contact = $contact[0];
?>
Name: <?php echo $contact->name; ?><br />
Email: <?php echo $contact->email_to; ?>
Hi, whats your joomla version ?
Sorry that would help wouldn't it? I am using latest version 1.57 and the most recent Chronoforms licensed version
No problems sure the code above will not work because its for J1.0.x, replace :
with
regards
Max
global $my, $database;
with
global $mainframe;
$database =& JFactory::getDBO();
$my = JFactory::getUser();
regards
Max
Hi Max
I hate to bother you again, you have been great. I tried the change to the query no errors this time but
Doesn't seem to be capturing the name and email of the member, am I using the right format to get this info into the email? I obviously need to bone up on my Joomla but if you could help me out I would much appreciate.
I hate to bother you again, you have been great. I tried the change to the query no errors this time but
Name: <?php echo $contact->name; ?><br />
Email: <?php echo $contact->email_to; ?>
Doesn't seem to be capturing the name and email of the member, am I using the right format to get this info into the email? I obviously need to bone up on my Joomla but if you could help me out I would much appreciate.
Hi madmaph,
There's a mess of different thing here. Let's start over. You are in Joomla 1.5 and you want to get user info, try this:
Bob
There's a mess of different thing here. Let's start over. You are in Joomla 1.5 and you want to get user info, try this:
<?php
$my = JFactory::getUser();
?>
Name: <?php echo $my->name; ?><br />
Email: <?php echo $my->email; ?>
Bob
hi madmaph,
I think the error is in the query, make it like this :
I think the error is in the query, make it like this :
$query = "SELECT * FROM #__contact_details WHERE user_id = '".$my->id."'";
Bingo!
The above code returns the result I needed. I was just trying to save the user from having to enter info we had already captured when they logged in. I am going to go vote for this product and considering the low cost of your license Chronoengine is easily the best bang for your buck product for enhancing a Joomla website.
<?php
$my = JFactory::getUser();
?>
Name: <?php echo $my->name; ?><br />
Email: <?php echo $my->email; ?>
The above code returns the result I needed. I was just trying to save the user from having to enter info we had already captured when they logged in. I am going to go vote for this product and considering the low cost of your license Chronoengine is easily the best bang for your buck product for enhancing a Joomla website.
great🙂
Bob/Madmaph - Can either of you shed some more light on this? What is the complete code and where exactly do we add this code to capture registered/logged in user details so that it auto populate in the form I created with the form wizard. The essence of the form is to allow the users to edit their record.
2) Also, how do I enable Chronoform to display the information submitted from the frontend in my admin (backend) so that I can keep a record of all submissions.
3) If (2) is possible, will admin be able to edit these records from the backend?
Thanks
2) Also, how do I enable Chronoform to display the information submitted from the frontend in my admin (backend) so that I can keep a record of all submissions.
3) If (2) is possible, will admin be able to edit these records from the backend?
Thanks
Hi omojesu,
1) In the wizard you need to create text fields (not input boxes) where you want this info to appear. I'd suggest that you also add a hidden field with the user_id in it. When the Wizard is ended you can edit the Form HTML to set the text in these fields. For example the user_name would look something like
2 & 3) If you created a tabel in ChronOForms you can use the Forms Manager to View Table Data and, I think, to edit it.
Bob
1) In the wizard you need to create text fields (not input boxes) where you want this info to appear. I'd suggest that you also add a hidden field with the user_id in it. When the Wizard is ended you can edit the Form HTML to set the text in these fields. For example the user_name would look something like
<p><?php echo $user->username; ?></p>
and so on for each field (You also need the snippet to get the user info at the start of the form html.2 & 3) If you created a tabel in ChronOForms you can use the Forms Manager to View Table Data and, I think, to edit it.
Bob
OK, not sure what I am doing wrong. I created the form below with the aid of the form builder and attempted to follow your directive here. The form displays well but the username, firstname and email are not being retrieved from the user session.
<?php
global $mainframe;
$database =& JFactory::getDBO();
$my = JFactory::getUser();
$query = "SELECT * FROM #__contact_details WHERE user_id = '".$my->id."'";
$database->setQuery( $query );
$contact = $database->loadObjectList();
$contact = $contact[0];
?>
<div class="form_item"><div class="form_element cf_heading"><h2 id="" class="cf_text">Members Update</h2></div><div class="clear">Â </div></div><div class="form_item"><div class="form_element cf_text"><span class="cf_text">Please use this form to update your information. This will allow the office to keep our database accurate.</span></div><div class="clear">Â </div></div><div class="form_item"><div class="form_element cf_hidden"><input value="<?php echo $my->id; ?>" id="user_id" name="user_id" type="hidden"></div><div class="clear">Â </div></div><div class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Username</label><input class="cf_inputbox" maxlength="150" size="30" id="username" name="username" disabled="disabled" value= "<?php echo $user->username; ?>"></div><div class="clear">Â </div></div><div class="form_item"><div class="form_element cf_dropdown"><label class="cf_label">Status</label><select class="cf_inputbox validate-selection" id="status" size="1" name="status"><option value="">Please select one...</option><option value="Mr">Mr.</option><option value="Mrs">Mrs.</option></select><a onclick="return false;" class="tooltiplink"><img src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" border="0" height="16" width="16"></a><div class="tooltipdiv">Status :: Please signify your status</div></div><div class="clear">Â </div></div><div class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Firstname*</label><input class="cf_inputbox required" maxlength="150" size="30" id="firstname" name="firstname" type="text" value="<?php echo $user->name; ?>"><a onclick="return false;" class="tooltiplink"><img src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" border="0" height="16" width="16"></a><div class="tooltipdiv">Firstname* :: Please enter your firstname here</div></div><div class="clear">Â </div></div><div class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Lastname</label><input class="cf_inputbox required" maxlength="150" size="30" id="lastname" name="lastname" type="text"><a onclick="return false;" class="tooltiplink"><img src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" border="0" height="16" width="16"></a><div class="tooltipdiv">Lastname :: Please enter your Lastname here</div></div><div class="clear">Â </div></div><div class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Email*</label><input class="cf_inputbox required validate-email" maxlength="150" size="30" id="email" name="email" type="text" value="<?php echo $user->username; ?>"><a onclick="return false;" class="tooltiplink"><img src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" border="0" height="16" width="16"></a><div class="tooltipdiv">Email* :: Verify your Email</div></div><div class="clear">Â </div></div><div class="form_item"><div class="form_element cf_password"><label class="cf_label">Password</label><input class="cf_inputbox required" maxlength="150" size="30" id="password" name="password" type="password"><a onclick="return false;" class="tooltiplink"><img src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" border="0" height="16" width="16"></a><div class="tooltipdiv">Password :: Enter your password</div></div><div class="clear">Â </div></div><div class="form_item"><div class="form_element cf_password"><label class="cf_label">Confirm Password*</label><input class="cf_inputbox required" maxlength="150" size="30" id="password2" name="password2" type="password"><a onclick="return false;" class="tooltiplink"><img src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" border="0" height="16" width="16"></a><div class="tooltipdiv">Confirm Password* :: Please confirm your password</div></div><div class="clear">Â </div></div><div class="form_item"><div class="form_element cf_heading"><h4 id="" class="cf_text">Address information</h4></div><div class="clear">Â </div></div><div class="form_item"><div class="form_element cf_text"><span class="cf_text">Please provide your most uptodate address information below</span></div><div class="clear">Â </div></div><div class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Address*</label><input class="cf_inputbox required" maxlength="150" size="50" id="address1" name="address1" type="text"><a onclick="return false;" class="tooltiplink"><img src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" border="0" height="16" width="16"></a><div class="tooltipdiv">Address* :: Please enter your street address</div></div><div class="clear">Â </div></div><div class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Address 2</label><input class="cf_inputbox" maxlength="150" size="50" id="address2" name="address2" type="text"></div><div class="clear">Â </div></div><div class="form_item"><div class="form_element cf_textbox"><label class="cf_label">City*</label><input class="cf_inputbox required" maxlength="150" size="30" id="city" name="city2" type="text"><a onclick="return false;" class="tooltiplink"><img src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" border="0" height="16" width="16"></a><div class="tooltipdiv">City* :: Please enter your city</div></div><div class="clear">Â </div></div><div class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Post Code*</label><input class="cf_inputbox required" maxlength="30" size="10" id="postcode" name="postcode" type="text"><a onclick="return false;" class="tooltiplink"><img src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" border="0" height="16" width="16"></a><div class="tooltipdiv">Post Code* :: Please enter your postal code</div></div><div class="clear">Â </div></div><div class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Country</label><input class="cf_inputbox required" maxlength="150" size="30" id="country" name="country" type="text" value="United Kingdom"><a onclick="return false;" class="tooltiplink"><img src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" border="0" height="16" width="16"></a><div class="tooltipdiv">Country :: Please enter your country of residence</div></div><div class="clear">Â </div></div><div class="form_item"><div class="form_element cf_heading"><h4 id="" class="cf_text">Contact Numbers</h4></div><div class="clear">Â </div></div><div class="form_item"><div class="form_element cf_text"><span class="cf_text">Please enter the most up to date contact numbers</span></div><div class="clear">Â </div></div><div class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Landline*</label><input class="cf_inputbox required validate-number" maxlength="15" size="30" id="landline" name="landline" type="text"><a onclick="return false;" class="tooltiplink"><img src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" border="0" height="16" width="16"></a><div class="tooltipdiv">Landline* :: Please enter your landline</div></div><div class="clear">Â </div></div><div class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Mobile #*</label><input class="cf_inputbox required validate-number" maxlength="150" size="30" id="mobile" name="mobile" type="text"><a onclick="return false;" class="tooltiplink"><img src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" border="0" height="16" width="16"></a><div class="tooltipdiv">Mobile #* :: Please enter your preferred phone number (Mobile # e.g: 07941444444))</div></div><div class="clear">Â </div></div><div class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Alternate #</label><input class="cf_inputbox" maxlength="150" size="30" id="Alternate_number" name="alternate_number" type="text"><a onclick="return false;" class="tooltiplink"><img src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" border="0" height="16" width="16"></a><div class="tooltipdiv">Alternate # :: Please enter any other alternate phone number that you can be contact at.</div></div><div class="clear">Â </div></div><div class="form_item"><div class="form_element cf_captcha"><label class="cf_label">Image Verification</label><span>{imageverification}</span><a onclick="return false;" class="tooltiplink"><img src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" border="0" height="16" width="16"></a><div class="tooltipdiv">Image Verification :: Please renter the code as shown</div></div><div class="clear">Â </div></div><div class="form_item"><div class="form_element cf_button"><input value="Submit" name="undefined" type="submit"></div><div class="clear">Â </div></div>
Hi,
Regards,
Max
<?php echo $user->username; ?>
I think this should be: <?php echo $my->username; ?>
?Regards,
Max
Thanks...that worked. Does anyone know what the field name for Lastname is on the Joomla registration form?
Hi omojesu,
AFAIK the Joomla Registration only has a 'Name' field. If you need to store the two separately on your form you have to recombine them for Joomla.
Bob
AFAIK the Joomla Registration only has a 'Name' field. If you need to store the two separately on your form you have to recombine them for Joomla.
Bob
Hi,
something like this:
in the onsubmit box!
regards
Max
something like this:
<?php
JRequest::setVar('name', JRequest::getVar('firstname').' '. JRequest::getVar('lastname'));
?>
in the onsubmit box!
regards
Max
Hi Bob/Madmaph
I am having similar issues with reading my data back out of my form table and autofilling my form fields. I would like the user to be able to log back in and edit thier form details, so I hope this is the best method to achieve this.
I have inserted the following into my form html:
Im using j1.5 in legacy and the latest release of chronoforms, if it makes any difference Ive also enabled the profiling plugin to link up with my cb users.
Im getting no errors, the data just isn't coming through, any ideas?
Thanx in advance, great component by the way
Dave
I am having similar issues with reading my data back out of my form table and autofilling my form fields. I would like the user to be able to log back in and edit thier form details, so I hope this is the best method to achieve this.
I have inserted the following into my form html:
<?php
global $mainframe;
$database =& JFactory::getDBO();
$my = JFactory::getUser();
$query = "SELECT * FROM #jos_chronoforms_CV_Registration WHERE cf_user_id = '".$my->id."'";
$database->setQuery( $query );
$contact = $database->loadObjectList();
$contact = $contact[0];
?>
and then further down in my fields I have the following :<select name="ddlNationality" value="<?php echo $contact->ddlNationality; ?>" id="ddlNationality" tabindex="8">
<option value="0">--SELECT--</option>
<option value="">-- select one --</option>
<option value="afghan">Afghan</option>
<option value="albanian">Albanian</option> etc...
Im using j1.5 in legacy and the latest release of chronoforms, if it makes any difference Ive also enabled the profiling plugin to link up with my cb users.
Im getting no errors, the data just isn't coming through, any ideas?
Thanx in advance, great component by the way
Dave
You are limited by the available fields in the original Joomla registration for. If the field you are trying to retrieve for the user is not available in the original Joomla form, then you cannot retrieve it unless you have customize (added) those fields in your registration table.
I hope that helped.
I hope that helped.
Hi Dave,
the select field will not accept a "value" attribute, disable the profile plugin because you already started the PHP way, to auto choose some value in the select field you need something like this :
Regards
Max
the select field will not accept a "value" attribute, disable the profile plugin because you already started the PHP way, to auto choose some value in the select field you need something like this :
<select ...etc>
<option <?php if($contact->somefield == "something")echo "selected"; ?> value="something">something</option>
Regards
Max
Hi Dave,
Looking at this a bit late I noticed that you have FROM #jos_chronoforms_CV_Registration in your code - that should be FROM #__chronoforms_CV_Registration. Joomla will replace the #__ with jos_ (or whatever prefix is used on your site).
Bob
Looking at this a bit late I noticed that you have FROM #jos_chronoforms_CV_Registration in your code - that should be FROM #__chronoforms_CV_Registration. Joomla will replace the #__ with jos_ (or whatever prefix is used on your site).
Bob
Hi All,
I'm think i'm trying to do something similar here. i have created a User Registration form but Joomla only collects "Name Field" and does not separate into "First Name" and "Last Name"... I thought about doing this... Have two fields "First Name" and "Last Name" and have it auto populate the "Name Field" which will display the Full name.
Example I enter...
First Name: Bill
Last Name: Smith
and have a Full Name field show as "Bill Smith"
If this makes any sense to anyone out and you think you can provide some assistance, please let me know.
Thanks in advance!🤨
I'm think i'm trying to do something similar here. i have created a User Registration form but Joomla only collects "Name Field" and does not separate into "First Name" and "Last Name"... I thought about doing this... Have two fields "First Name" and "Last Name" and have it auto populate the "Name Field" which will display the Full name.
Example I enter...
First Name: Bill
Last Name: Smith
and have a Full Name field show as "Bill Smith"
If this makes any sense to anyone out and you think you can provide some assistance, please let me know.
Thanks in advance!🤨
Hi Boogieman,
Joomla only has a single 'Name' field in the jos_users table. You can fix this by adding a hidden field with name='name' in your form then setting its value in the OnSubmit Before box.
Bob
Joomla only has a single 'Name' field in the jos_users table. You can fix this by adding a hidden field with name='name' in your form then setting its value in the OnSubmit Before box.
<?php
$first_name = JRequest::getVar('first_name', '', 'post');
$last_name = JRequest::getVar('last_name', '', 'post');
$name = $first_name." ".$last_name;
JRequest::setVar('name', $name);
?>
Bob
So instead of using the "Display Name" i can get rid of that field, Hide it and submit and get the same result?
I did this but don't think this is correct.
When i submit, i get an error "Please enter Name"
~Thanks.
<tr>
<td width="150">First Name</td>
<td>
<INPUT class="cf_inputbox required" id="FirstName" maxLength="150" size="30" name="FirstName" ></td>
</tr>
<tr>
<td>Last Name</td>
<td><INPUT class="cf_inputbox required" id="LastName" maxLength="150" size="30" name="LastName" >
<input type="hidden" name="Name" id="Name">
</td>
</tr>
When i submit, i get an error "Please enter Name"
~Thanks.
No, its not. But i check the backend and its not populating the name field either. However, I am getting the firstname and last name now. Anything else it could be?
I did alter the code you sent me.
to match the names in the db.
<?php
$first_name = JRequest::getVar('FirstName', '', 'post');
$last_name = JRequest::getVar('LastName', '', 'post');
$name = $FirstName." ".$LastName;
JRequest::setVar('Name', $Name);
?>
to match the names in the db.
I did alter the code you sent me.
<?php
$first_name = JRequest::getVar('FirstName', '', 'post');
$last_name = JRequest::getVar('LastName', '', 'post');
$name = $FirstName." ".$LastName;
JRequest::setVar('Name', $Name);
?>
to match the names in the db.
yes, this was necessary, so it works now ?
Max
do you use the Joomla registration plugin of Chronoforms ? if so then you need to add "Name" as the field name for "Name"
Max
Max
Hi there,
Yes, i'm using the Joomla Registration.
Do you mean this?
Will this put combine the first name and last name into the Name field? Example:
First Name: Bill
Last Name: Smith
Result:
Name: Bill Smith
Thanks.
Yes, i'm using the Joomla Registration.
<?php
$first_name = JRequest::getVar('FirstName', '', 'post');
$last_name = JRequest::getVar('LastName', '', 'post');
$name = $Name;
JRequest::setVar('name', $Name);
?>
Do you mean this?
Will this put combine the first name and last name into the Name field? Example:
First Name: Bill
Last Name: Smith
Result:
Name: Bill Smith
Thanks.
I tried that and still get...
It will not add the new user to the Joomla registration, yet it ads it to the Chronoform db.
~Alex
Please enter your name
It will not add the new user to the Joomla registration, yet it ads it to the Chronoform db.
~Alex
Hi Alex,
which Chronoforms version ? please get V3.1 RC4!
regards
Max
which Chronoforms version ? please get V3.1 RC4!
regards
Max
Hi,
I just upgraded and still get the same results. Name field is not being populated. Any other thoughts? Thanks. :wink:
I just upgraded and still get the same results. Name field is not being populated. Any other thoughts? Thanks. :wink:
do you have this code in the onsubmit before email and the plugin runs AFTER email (this is configured in the Joomla registration plugin config page) ?
This topic is locked and no more replies can be posted.