Hello,
My setup details - CMSMS: 1.2.2 FEU: 1.3.1 CustomContent: 1.4.10 FormBuilder: 0.4.4
I would like to pass the FEU user data (not just the customcontent_loginname) to a FormBuilder form so that the form is pre-loaded with the logged in user's details.
Aspects of this are covered in various posts and by using the excellent help provided by CalGuy1000 and others I have been able to come up with the following UDT to access the data I need:
-------------------------------------------------------------------------
global $gCms;
$feusers = $gCms->modules['FrontEndUsers']['object'];
if( $feusers )
{
$uid = $feusers->LoggedInId();
$properties = $feusers->GetUserProperties($uid);
$firstname= ( $properties [1][data]);
$lastname= ( $properties [2][data]);
$email= ( $properties [3][data]);
$phone= ( $properties [4][data]);
echo $firstname . " " . $lastname . " " . $email . " " . $phone ;
}
-----------------------------------------------------------------------
So the information is there, I can access it, and (using the test 'echo' statement) I can display it correctly on a page. To pre-load the variables into a FormBuilder form I thought I should be able to use:
{cms_module module='FormBuilder' form='b_tempted' value_fld25= $firstname}
After all, as I have the variable $firstname echoing to the same page as the form I reasoned that it must be accessible. This does not seem to be the case though. I have tried many variations but no matter what I do I cannot seem to get $firstname to pre-load into the form. This would be an incredibly useful thing to be able to do.
If anyone can help with this I would be very grateful. Thanks in advance - Michael.
[Solved] Passing FrontEndUser user data to a FormBuilder form
[Solved] Passing FrontEndUser user data to a FormBuilder form
Last edited by tosd on Fri Dec 21, 2007 3:32 am, edited 1 time in total.
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: Passing FrontEndUser user data to a FormBuilder form
You're 1/2 way there....
Your UDT is in php space, whereas the {cms_module module=FormBuilder...} stuff is in smarty space.
You need to assign the appropriate values to smarty.
i.e:
Here's your udt:
-------------------------------------------------------------------------
-----------------------------------------------------------------------
if you change it to:
-------------------------------------------------------------------------
-----------------------------------------------------------------------
and call this udt above the call to formbuilder, then things would probably just 'work'
btw... this has already been done with the CustomContent module.
would probably just.... work.
Your UDT is in php space, whereas the {cms_module module=FormBuilder...} stuff is in smarty space.
You need to assign the appropriate values to smarty.
i.e:
Here's your udt:
-------------------------------------------------------------------------
Code: Select all
global $gCms;
$feusers = $gCms->modules['FrontEndUsers']['object'];
if( $feusers )
{
$uid = $feusers->LoggedInId();
$properties = $feusers->GetUserProperties($uid);
$firstname= ( $properties [1][data]);
$lastname= ( $properties [2][data]);
$email= ( $properties [3][data]);
$phone= ( $properties [4][data]);
echo $firstname . " " . $lastname . " " . $email . " " . $phone ;
}
if you change it to:
-------------------------------------------------------------------------
Code: Select all
global $gCms;
$feusers = $gCms->modules['FrontEndUsers']['object'];
if( $feusers )
{
$uid = $feusers->LoggedInId();
$properties = $feusers->GetUserProperties($uid);
$firstname= ( $properties [1][data]);
$lastname= ( $properties [2][data]);
$email= ( $properties [3][data]);
$phone= ( $properties [4][data]);
$smarty->assign('firstname',$firstname);
$smarty->assign('lastname',$lastname);
$smarty->assign('email',$email);
$smarty->assign('phone',$phone);
}
and call this udt above the call to formbuilder, then things would probably just 'work'
btw... this has already been done with the CustomContent module.
Code: Select all
{cms_module module='FormBuilder' form='b_tempted' value_fld25= $ccuser->property('firstname')}
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Re: Passing FrontEndUser user data to a FormBuilder form
Hi CalGuy1000,
You said your suggestion "would probably just.... work" - and it did
That really is an excellent solution. Many thanks for your prompt response.
I have got so much out of your contributions to this forum I would just like to take this opportunity the thank you. The generous way you give your time to help "learners" such as myself is very much appreciated.
Cheers, Michael
You said your suggestion "would probably just.... work" - and it did

I have got so much out of your contributions to this forum I would just like to take this opportunity the thank you. The generous way you give your time to help "learners" such as myself is very much appreciated.
Cheers, Michael
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: Passing FrontEndUser user data to a FormBuilder form
Kudos?
I'm trying to get ahead of cyberman
I'm trying to get ahead of cyberman

Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Re: Passing FrontEndUser user data to a FormBuilder form
Oops, I spoke too soon CalGuy1000 - but you can still have the kudos - it's been earned many times over 
I checked the solution of assigning the php variables to smarty accessible variables across multiple user data and I discovered that the user properties don't seem to be assigned to the array consistently. To demonstrate this I did a dump of the arrays for two users with the following results:
Array (
[0] => Array ( [id] => 47 [userid] => 4 [title] => postcode [data] => 3116 )
[1] => Array ( [id] => 48 [userid] => 4 [title] => state [data] => VIC )
[2] => Array ( [id] => 49 [userid] => 4 [title] => town [data] => XXXXXX )
[3] => Array ( [id] => 50 [userid] => 4 [title] => street [data] => XXXXXXXX Court )
[4] => Array ( [id] => 51 [userid] => 4 [title] => st_number [data] => 4 )
[5] => Array ( [id] => 52 [userid] => 4 [title] => phone [data] => XX XXXX XXXX )
[6] => Array ( [id] => 53 [userid] => 4 [title] => email [data] => XXXX@XXXXX.com.au )
[7] => Array ( [id] => 54 [userid] => 4 [title] => lastname [data] => XXXX )
[8] => Array ( [id] => 55 [userid] => 4 [title] => firstname [data] => Michael )
[9] => Array ( [id] => 56 [userid] => 4 [title] => country [data] => Australia )
[10] => Array ( [id] => 57 [userid] => 4 [title] => dob [data] => 29/09/53 ) )
Array (
[0] => Array ( [id] => 66 [userid] => 5 [title] => firstname [data] => Sharyn )
[1] => Array ( [id] => 65 [userid] => 5 [title] => lastname [data] => XXXXX )
[2] => Array ( [id] => 64 [userid] => 5 [title] => email [data] => XXXXXX@paths2XXXXX.com.au )
[3] => Array ( [id] => 63 [userid] => 5 [title] => phone [data] => XX XXXX XXXX )
[4] => Array ( [id] => 62 [userid] => 5 [title] => st_number [data] => 4 )
[5] => Array ( [id] => 61 [userid] => 5 [title] => street [data] => XXXXX Court )
[6] => Array ( [id] => 60 [userid] => 5 [title] => town [data] => XXXXXpark )
[7] => Array ( [id] => 59 [userid] => 5 [title] => state [data] => VIC )
[8] => Array ( [id] => 58 [userid] => 5 [title] => postcode [data] => 3116 )
[9] => Array ( [id] => 67 [userid] => 5 [title] => country [data] => Australia )
[10] => Array ( [id] => 68 [userid] => 5 [title] => dob [data] => 25/10/56 ) )
Note that, for example, the firstname and lastname properties are assigned to different array numbers. This means that calling back the data when referencing the array element gives inconsistent results. The problem seems to be in the way the data is written to the database from the FEU module.
Any suggestions? The other solution by the way of using $ccuser in the module tag I couldn't get to work. I think it is getting hung up with the multidimensional array.
Thanks in advance, Michael.

I checked the solution of assigning the php variables to smarty accessible variables across multiple user data and I discovered that the user properties don't seem to be assigned to the array consistently. To demonstrate this I did a dump of the arrays for two users with the following results:
Array (
[0] => Array ( [id] => 47 [userid] => 4 [title] => postcode [data] => 3116 )
[1] => Array ( [id] => 48 [userid] => 4 [title] => state [data] => VIC )
[2] => Array ( [id] => 49 [userid] => 4 [title] => town [data] => XXXXXX )
[3] => Array ( [id] => 50 [userid] => 4 [title] => street [data] => XXXXXXXX Court )
[4] => Array ( [id] => 51 [userid] => 4 [title] => st_number [data] => 4 )
[5] => Array ( [id] => 52 [userid] => 4 [title] => phone [data] => XX XXXX XXXX )
[6] => Array ( [id] => 53 [userid] => 4 [title] => email [data] => XXXX@XXXXX.com.au )
[7] => Array ( [id] => 54 [userid] => 4 [title] => lastname [data] => XXXX )
[8] => Array ( [id] => 55 [userid] => 4 [title] => firstname [data] => Michael )
[9] => Array ( [id] => 56 [userid] => 4 [title] => country [data] => Australia )
[10] => Array ( [id] => 57 [userid] => 4 [title] => dob [data] => 29/09/53 ) )
Array (
[0] => Array ( [id] => 66 [userid] => 5 [title] => firstname [data] => Sharyn )
[1] => Array ( [id] => 65 [userid] => 5 [title] => lastname [data] => XXXXX )
[2] => Array ( [id] => 64 [userid] => 5 [title] => email [data] => XXXXXX@paths2XXXXX.com.au )
[3] => Array ( [id] => 63 [userid] => 5 [title] => phone [data] => XX XXXX XXXX )
[4] => Array ( [id] => 62 [userid] => 5 [title] => st_number [data] => 4 )
[5] => Array ( [id] => 61 [userid] => 5 [title] => street [data] => XXXXX Court )
[6] => Array ( [id] => 60 [userid] => 5 [title] => town [data] => XXXXXpark )
[7] => Array ( [id] => 59 [userid] => 5 [title] => state [data] => VIC )
[8] => Array ( [id] => 58 [userid] => 5 [title] => postcode [data] => 3116 )
[9] => Array ( [id] => 67 [userid] => 5 [title] => country [data] => Australia )
[10] => Array ( [id] => 68 [userid] => 5 [title] => dob [data] => 25/10/56 ) )
Note that, for example, the firstname and lastname properties are assigned to different array numbers. This means that calling back the data when referencing the array element gives inconsistent results. The problem seems to be in the way the data is written to the database from the FEU module.
Any suggestions? The other solution by the way of using $ccuser in the module tag I couldn't get to work. I think it is getting hung up with the multidimensional array.
Thanks in advance, Michael.
[Solved] Re: Passing FrontEndUser user data to a FormBuilder form
Hello,
After much playing around I have sorted out this problem so I thought someone else may be interested in the result. The UDT (in my case called {member_data} I developed to extract the required property values from the FEU database is as follows:
--------------------------------------------------------------------------------------
global $gCms;
$feusers = $gCms->modules['FrontEndUsers']['object'];
if( $feusers )
{
$uid = $feusers->LoggedInId();
$user_data = $feusers->GetUserProperties($uid);
foreach ($user_data as $record => $row_num) {
foreach ($row_num as $property => $property_data){
if ($property_data == 'firstname') {
$firstname = ($user_data [$record] [data]);
$smarty->assign('firstname',$firstname);
} elseif ($property_data == 'lastname') {
$lastname = ($user_data [$record] [data]);
$smarty->assign('lastname',$lastname);
} elseif ($property_data == 'email') {
$email = ($user_data [$record] [data]);
$smarty->assign('email',$email);
} elseif ($property_data == 'phone') {
$phone = ($user_data [$record] [data]);
$smarty->assign('phone',$phone);
} elseif ($property_data == 'postcode') {
$postcode = ($user_data [$record] [data]);
$smarty->assign('postcode',$postcode);
} elseif ($property_data == 'town') {
$town = ($user_data [$record] [data]);
$smarty->assign('town',$town);
}
}
}
}
-------------------------------------------------------------------------------
A few notes:
1. The line "$user_data = $feusers->GetUserProperties($uid);" fetched the FEU array values.
2. The outer foreach loop iterates through the rows of the multidimensional array.
3. The inner foreach loop iterates through the properties of each row, looking via the elseif statements for the required property - firstname, lastname etc
4. Lines such as "$firstname = ($user_data [$record] [data]);" return the data (the actual name etc) for the row the elseif selects.
5. Lines such as "$smarty->assign('firstname',$firstname);" make the variables available to smarty tags (see below)
The tag entries in the template to return the variables and call the form are:
-------------------------------------------------------------------------------
{member_data}
{cms_module module='FormBuilder' form='b_tempted' value_fld25= $firstname value_fld26= $lastname value_fld27= $email value_fld28= $phone value_fld29= $postcode value_fld32= $town}
-------------------------------------------------------------------------------
Notes:
1. {member_data} runs the UDT(above) that sets up the variables with the user data and makes them available to the FormBuilder module call.
2. Assignments such as "value_fld25= $firstname" pre-load the returned user data automatically into the form in the matching field. Note that I have used field numbers - field names can also be used.
I hope the info helps someone. Cheers, Michael.
After much playing around I have sorted out this problem so I thought someone else may be interested in the result. The UDT (in my case called {member_data} I developed to extract the required property values from the FEU database is as follows:
--------------------------------------------------------------------------------------
global $gCms;
$feusers = $gCms->modules['FrontEndUsers']['object'];
if( $feusers )
{
$uid = $feusers->LoggedInId();
$user_data = $feusers->GetUserProperties($uid);
foreach ($user_data as $record => $row_num) {
foreach ($row_num as $property => $property_data){
if ($property_data == 'firstname') {
$firstname = ($user_data [$record] [data]);
$smarty->assign('firstname',$firstname);
} elseif ($property_data == 'lastname') {
$lastname = ($user_data [$record] [data]);
$smarty->assign('lastname',$lastname);
} elseif ($property_data == 'email') {
$email = ($user_data [$record] [data]);
$smarty->assign('email',$email);
} elseif ($property_data == 'phone') {
$phone = ($user_data [$record] [data]);
$smarty->assign('phone',$phone);
} elseif ($property_data == 'postcode') {
$postcode = ($user_data [$record] [data]);
$smarty->assign('postcode',$postcode);
} elseif ($property_data == 'town') {
$town = ($user_data [$record] [data]);
$smarty->assign('town',$town);
}
}
}
}
-------------------------------------------------------------------------------
A few notes:
1. The line "$user_data = $feusers->GetUserProperties($uid);" fetched the FEU array values.
2. The outer foreach loop iterates through the rows of the multidimensional array.
3. The inner foreach loop iterates through the properties of each row, looking via the elseif statements for the required property - firstname, lastname etc
4. Lines such as "$firstname = ($user_data [$record] [data]);" return the data (the actual name etc) for the row the elseif selects.
5. Lines such as "$smarty->assign('firstname',$firstname);" make the variables available to smarty tags (see below)
The tag entries in the template to return the variables and call the form are:
-------------------------------------------------------------------------------
{member_data}
{cms_module module='FormBuilder' form='b_tempted' value_fld25= $firstname value_fld26= $lastname value_fld27= $email value_fld28= $phone value_fld29= $postcode value_fld32= $town}
-------------------------------------------------------------------------------
Notes:
1. {member_data} runs the UDT(above) that sets up the variables with the user data and makes them available to the FormBuilder module call.
2. Assignments such as "value_fld25= $firstname" pre-load the returned user data automatically into the form in the matching field. Note that I have used field numbers - field names can also be used.
I hope the info helps someone. Cheers, Michael.
Last edited by tosd on Sat Feb 09, 2008 4:48 am, edited 1 time in total.
Re: [Solved] Passing FrontEndUser user data to a FormBuilder form
Yes, the issue of passing FEU data to a Formbuilder form is solved but I am now having difficulty with submission. Essentially, even though the data pre-populates the form (apparently) correctly, submitting the form generates the following error:
"Warning: htmlspecialchars() expects parameter 1 to be string, array given in /home/xxxxxx/public_html/modules/FormBuilder/classes/DispositionEmailBase.class.php on line 145"
When I view source the data appears to be a normal value string.
If the variables are not passed to the form but manually typed in, no errors are generated.
If anyone can help with this I would be very grateful. I have checked other posts but have not come across a solution.
"Warning: htmlspecialchars() expects parameter 1 to be string, array given in /home/xxxxxx/public_html/modules/FormBuilder/classes/DispositionEmailBase.class.php on line 145"
When I view source the data appears to be a normal value string.
If the variables are not passed to the form but manually typed in, no errors are generated.
If anyone can help with this I would be very grateful. I have checked other posts but have not come across a solution.
Re: [Solved] Passing FrontEndUser user data to a FormBuilder form
Good tips....
Rafain, is there a way to do this with the 'email results to' field? I've got an address sitting in a special user property from feu that I'd like to auto-populate the form with, so the form is sent to that address.
Any help is appreciated.
Thx,
Jeff T.
Rafain, is there a way to do this with the 'email results to' field? I've got an address sitting in a special user property from feu that I'd like to auto-populate the form with, so the form is sent to that address.
Any help is appreciated.
Thx,
Jeff T.
Mmmmm... Tasty.
Re: [Solved] Passing FrontEndUser user data to a FormBuilder
Thanks for all the tips that helped me a lot!
I have called user details this way:
Lex
I have called user details this way:
Thanks again,{cms_module module=FrontEndUsers form="silent"}
Lex