Accessing FrontEnd User properties in Logout Template

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
youngs
Forum Members
Forum Members
Posts: 10
Joined: Wed Mar 02, 2011 7:35 am

Accessing FrontEnd User properties in Logout Template

Post 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 -->
youngs
Forum Members
Forum Members
Posts: 10
Joined: Wed Mar 02, 2011 7:35 am

Re: Accessing FrontEnd User properties in Logout Template

Post 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.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: Accessing FrontEnd User properties in Logout Template

Post 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...
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Accessing FrontEnd User properties in Logout Template

Post 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()}.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: Accessing FrontEnd User properties in Logout Template

Post by Dr.CSS »

It give you the ability to wrap content in tags that hide it if not logged in...
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Accessing FrontEnd User properties in Logout Template

Post 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
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: Accessing FrontEnd User properties in Logout Template

Post by Dr.CSS »

That is for an older version, which is not so good to have laying around :(...
youngs
Forum Members
Forum Members
Posts: 10
Joined: Wed Mar 02, 2011 7:35 am

Re: Accessing FrontEnd User properties in Logout Template

Post 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?
zenmaster
New Member
New Member
Posts: 7
Joined: Wed Jan 26, 2011 12:46 pm

Re: Accessing FrontEnd User properties in Logout Template

Post 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>
youngs
Forum Members
Forum Members
Posts: 10
Joined: Wed Mar 02, 2011 7:35 am

Re: Accessing FrontEnd User properties in Logout Template

Post by youngs »

Thanks for the code sample but it does not work for me. Any suggestions?
Post Reply

Return to “Modules/Add-Ons”