Page 1 of 1

Accessing FrontEnd User properties in Logout Template

Posted: Fri Mar 04, 2011 4:59 pm
by youngs
I am running CMS made simple 1.9.3, php 5.3.5, mysql 5.1.55, apache 2.2.17 on fedora 14. I have the modules FrontEndUser version 1.12.12 and CustomContent version 1.7.3 installed

In the logout form I would like to replace the $username with the property of the logged in user's first name. I am encrypting the users first and last name in the DB.

I've done several hours of Google searches but I have not been able to find a solution that works.

First I created a UDT called get_properties with the following:
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);
}
Here is an example of what I've tried in the FrontEnd User logout template:
{get_properties}
<!-- Logout form template -->
<p>{$prompt_loggedin}&nbsp;{$firstname}</p>
<p><a href="{$url_logout}" title="{$mod->Lang('info_logout')}">{$mod->Lang('logout')}</a></p>
<!-- Logout form template -->

Re: Accessing FrontEnd User properties in Logout Template

Posted: Tue Mar 08, 2011 2:49 am
by youngs
I have logged into the my site using my test account and I am using the following code on one of my pages as a test.
{if $customcontent_loggedin > 0}
<p>Welcome <strong>{$customcontent_loginname}</strong></p>
{$feu_smarty->get_user_properties($customcontent_loggedin,'userprops')}
<h3>Userprops</h3>
{$userprops|print_r}
{else}
<p>You are not logged in.</p>{/if}

From the above code I am getting the following response:

Welcome testuser@test.com
Userprops
1

The user belongs to a group with the following properties

firstname
lastname
secretquestion
name

All use the default setting except secretquestion which I've set to be stored in the database encrypted.

Re: Accessing FrontEnd User properties in Logout Template

Posted: Tue Mar 08, 2011 5:38 pm
by Dr.CSS
I think the correct calls are to use ccuser not customcontent, look in custom content help, you may get more if you include the {get template vars} tag, look for it under extensions > tags...

Re: Accessing FrontEnd User properties in Logout Template

Posted: Tue Mar 08, 2011 5:55 pm
by Wishbone
Dr. CSS,

I had asked this question on another thread, but haven't received an answer. What does CustomContent give me that I can't get directly from FEU? I've been using {if $FrontEndUsers->LoggedIn()} in my templates instead of {if $ccuser->loggedin()}.

Re: Accessing FrontEnd User properties in Logout Template

Posted: Tue Mar 08, 2011 6:01 pm
by Dr.CSS
It give you the ability to wrap content in tags that hide it if not logged in...

Re: Accessing FrontEnd User properties in Logout Template

Posted: Tue Mar 08, 2011 6:51 pm
by Wishbone
Thanks for the clarification.

Regarding your comment about $customcontent variable, that's how it's listed in the FAQ.

http://wiki.cmsmadesimple.org/index.php ... om_Content

Re: Accessing FrontEnd User properties in Logout Template

Posted: Tue Mar 08, 2011 8:21 pm
by Dr.CSS
That is for an older version, which is not so good to have laying around :(...

Re: Accessing FrontEnd User properties in Logout Template

Posted: Wed Mar 09, 2011 6:07 am
by youngs
I was able to get the front end user property for firstname by using: {$ccuser->property('firstname')}

Here is what my log out template looks like now.
<!-- Logout form template -->
<p>{$prompt_loggedin}&nbsp;{$ccuser->property('firstname')}</p>
<p><a href="{$url_logout}" title="{$mod->Lang('info_logout')}">{$mod->Lang('logout')}</a></p>
<!-- Logout form template -->

No matter what I tried I could not get any properties out of using $feu_smarty->get_user_properties. Is this broken in frontend user 1.12.12?

Re: Accessing FrontEnd User properties in Logout Template

Posted: Thu Mar 10, 2011 12:10 am
by zenmaster
I know! I know!

This is how you do it -

Code: Select all

{$feu_smarty->get_user_properties($userid,'userprops')}
<p><strong>{$prompt_loggedin}&nbsp;{$userprops.name}</strong><p>

Re: Accessing FrontEnd User properties in Logout Template

Posted: Thu Mar 10, 2011 2:29 pm
by youngs
Thanks for the code sample but it does not work for me. Any suggestions?