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:
Code: Select all
// 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;