• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Get an Admin / FEU user's Full Name
PostPosted: Fri Feb 26, 2010 10:46 am 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Sat Mar 24, 2007 8:28 am
Posts: 421
Location: Long Beach, CA
I needed CGBlog to display a user's full name instead of their username, so I created this tag, called GetFullName
it does require the username as a parameter though.

\$1:
global $gCms;
$db =& $gCms->GetDb();
$user_name = $params['username'];

$query = "SELECT first_name, last_name FROM ".cms_db_prefix()."users WHERE username=?";
$row = $db->GetRow($query, array($user_name));
if($row)
{
   $result = $row['first_name'] . " " . $row['last_name'];
}
else
{
   $result = "Username: $user_name doesn't exist";
}

return $result;


Next, you can use it in your CGBlog templates like this:

\$1:
<div class="CGBlogPostAuthor">{GetFullName username=$entry->author}</div>


You can probably use it as well in modules like News

Hope somebody else finds this useful, thanks to Stikki for the help in making it work :-)

_________________
Twitter: @cmsms_es


Last edited by hexdj on Wed Mar 03, 2010 11:32 pm, edited 1 time in total.

Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Get an Admin user's Full Name
PostPosted: Wed Mar 03, 2010 9:20 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Sat Mar 24, 2007 8:28 am
Posts: 421
Location: Long Beach, CA
OK this UDT has been revamped, because in my site I needed certain FEU users to post articles to CGBlog, using the FEsubmit option, therefore the above UDT wouldn't get their actual name, as they're stored in different places in the Database.
Once again many thanks to Stikki for all the Help.

So now two parameters are accepted in the call:
- username (this is the user name that you want to get the full name from)
- feufield (this is the field that you want to fetch from FEU properties)

In my case I created a Property in FEU which holds a user's full name and I called it 'name'
so my call in my CGBlog template looks like this:
{GetFullName username=$entry->author feufield='name'}

UDT:
\$1:
// This UDT returns the "Full Name" of an Admin User, requires the username as a param
global $gCms;
$db =& $gCms->GetDb();

$user_name = isset($params['username']) ? $params['username'] : "";

$feu_field = isset($params['feufield']) ? $params['feufield'] : "";

$query = "SELECT first_name, last_name FROM ".cms_db_prefix()."users WHERE username=?";
$row = $db->GetRow($query, array($user_name));
if($row)
{
   $result = $row['first_name'] . " " . $row['last_name'];
}
else
{

 if($gCms->modules['FrontEndUsers']['object'] && !empty($feu_field)) {

   $query = "SELECT id FROM ".cms_db_prefix()."module_feusers_users WHERE username=?";
   $feid = $db->GetOne($query, array($user_name));

   if($feid)
   {
   $query = "SELECT data FROM ".cms_db_prefix()."module_feusers_properties WHERE userid=? AND title=?";
   $result = $db->GetOne($query, array($feid,$feu_field));
  
   }
  
 }
}

if(!$result)
{
   $result = "Username: $user_name doesn't exist or feufield is not set";
}

return $result;

_________________
Twitter: @cmsms_es


Last edited by hexdj on Sun Mar 07, 2010 12:05 am, edited 1 time in total.

Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Get an Admin / FEU user's Full Name
PostPosted: Thu Jun 07, 2012 12:01 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Tue Jun 20, 2006 11:38 am
Posts: 41
Location: Italy
Hi all,

Can someone please tell how I can get this UDT work in CMSMS 1.10.3 and CGBlog 1.9.8; Blog entries have to be submitted using Feusubmit

Using hexdj UDT:
When an admin post a blog entry, his name is correctly show but when the blog entry is posted using FEUsubmit, I get "Username: name@website.com doesn't exist or feufield is not set"

Any help please...


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Get an Admin / FEU user's Full Name
PostPosted: Thu Jun 07, 2012 6:42 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Tue Aug 12, 2008 9:30 pm
Posts: 2071
Location: Feldkirchen in Kärnten, Austria
Most possibly you have to change

\$1:
global $gCms

to
\$1:
$gCms = cmsms();

and
\$1:
$gCms->modules['FrontEndUsers']['object']

to
\$1:
cms_utils::get_module('FrontEndUsers')

_________________
CMSMS Blog - I do this!
Forge profile
Github profile
Twitter
=============================================
Support CMSMS


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
A2 Hosting