Page 1 of 1
LISE get Author variable
Posted: Fri Sep 24, 2021 7:10 pm
by andrewvideouk
Hi guys
Do anyone know how to get the Author full name in LISE?
Things I tried in the template
owner: {$item->owner} This only gives me the uid of the user.
{cms_admin_user uid={$item->owner} mode=fullname} This only works in the backend.
{PostAuthor username=$item->owner} gives me user not found.
Thank you.
Re: LISE get Author variable
Posted: Sat Sep 25, 2021 10:42 pm
by andrewvideouk
For now I would have to use this. But not good if we have to add more users.
Code: Select all
{if $item->owner == '1'}
user full name 1
{elseif $item->owner == '2'}
user full name 2
{elseif $item->owner == '3'}
user full name 3
{/if}
Re: LISE get Author variable
Posted: Sun Sep 26, 2021 2:47 pm
by DIGI3
Here's a UDT you can use to get the admin user's full name. Call it get_admin_name:
Code: Select all
$gCms = cmsms();
$db = $gCms->GetDb();
$user_id = $params['user_id'];
$query = "SELECT first_name, last_name FROM ". cms_db_prefix() . "users WHERE user_id=?";
$row = $db->GetRow($query, array($user_id));
if($row)
{
$result = $row['first_name'] . " " . $row['last_name'];
}
else
{
$result = "User ID: $user_id doesn't exist";
}
return $result;
Then in your LISE template you should be able to use {get_admin_name user_id=$item->owner}
Re: LISE get Author variable (Solved)
Posted: Wed Sep 29, 2021 7:28 pm
by andrewvideouk
Thank you so much that work great.