Display Authors full name in CGBlog instead of Username

When using CGBlog module and writing posts, the displayed Author name using {$entry->author} is always our Username.

I think this is not very wise, since we are providing our Administration Username for whole wide world. Ok there would be a workaround like creating another user with only Editor rights, so this wouldn't do much harm but do you really want to display something like "chiwawa" or whatever is your preferred Username.

Well i prefer a full Authors name, it looks more Personal and here comes this small User Defined Tag to help.

Create new UDT, call it authorname and copy/paste the code below.

$db = cmsms()->GetDb();
$FEU = cms_utils::get_module('FrontEndUsers');

$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(
if ($row) {
    $result = $row['first_name'] . " " . $row['last_name'];
} else {
    if (is_object($FEU) && !empty($feu_field)) {
        $query = "SELECT id FROM " . cms_db_prefix() . "module_feusers_users WHERE username=?";
        $feid  = $db->GetOne($query, array(
        if ($feid) {
            $query  = "SELECT data FROM " . cms_db_prefix() . "module_feusers_properties WHERE userid=? AND title=?";
            $result = $db->GetOne($query, array(
if (!$result) {
    $result = "Username: $user_name doesn't exist or feufield is not set";
return $result;

Now in our Blog templates we can use the UDT to get the Author Name like this.

{if $entry->author}
<div class="author">{authorname username=$entry->author}</div>