php: nickname of the current user
Permalink
Hello friends,
I try to include the nickname of a created user in a php.
It works with the username of the original author of the page. However, I would like the nickname of the current user.
Here is the working code, which tells me the username of the original author (not the one set in the Sitemap):
<div class="col-xs-12">
<?php if ($includeName): ?>
<h4 class="ccm-page-list-title"><a href="<?php echo $url; ?>"><?php echo $title; ?></a></h4>
<?php endif; ?>
<div class="thin-text">
contact person: <?php echo $original_author?>
</div>
is shown:
contact person: Originalautor256;
Therefore the user name of the original author who created the page.
I would like to enter the nickname of the currently registered user instead of the original author.
Does anyone know the code with which I can identify the nickname of the current user?
Thanks in advance for your help.
Marina
I try to include the nickname of a created user in a php.
It works with the username of the original author of the page. However, I would like the nickname of the current user.
Here is the working code, which tells me the username of the original author (not the one set in the Sitemap):
<div class="col-xs-12">
<?php if ($includeName): ?>
<h4 class="ccm-page-list-title"><a href="<?php echo $url; ?>"><?php echo $title; ?></a></h4>
<?php endif; ?>
<div class="thin-text">
contact person: <?php echo $original_author?>
</div>
is shown:
contact person: Originalautor256;
Therefore the user name of the original author who created the page.
I would like to enter the nickname of the currently registered user instead of the original author.
Does anyone know the code with which I can identify the nickname of the current user?
Thanks in advance for your help.
Marina
I need the NICKNAME (attribute) of user. :-)
There is not by default in C5 a "nickname" attribute for the user. So you will need to get the attribute handle of the attribute you are trying to get, then do something like this
<?php // get the current user $u = new User(); // check that we really have a user and that the user is logged in if (is_object($u) && $u->isLoggedIn()) { $ui = UserInfo::getByID($u->getUserID()) $nickname = $ui->getAttribute('attribute_handle'); } ?>
Thanks, and how do I get this user info on the preview of the page list?
I have set the USER in page attributes on the page, see screenshot in the Attachment.
I do not need "postet by: username original_author, I need at this point the NICKNAME of the USER of the page. The original author is me. The original author is shown my user name Marina68. Instead I want to see in my sample the nickname of the user "Hendrik.Faber", so Result:
"created by: Hendrik Faber"
How I can view the NICKNAME of the USER of the page on the preview of the PAGE LIST? There is no "User" and "User Nickname" setting in the page list. I need to manually paste this into php.
But how? And in which PHP file?
Thanks,
Marina (a newbie!)
I have set the USER in page attributes on the page, see screenshot in the Attachment.
I do not need "postet by: username original_author, I need at this point the NICKNAME of the USER of the page. The original author is me. The original author is shown my user name Marina68. Instead I want to see in my sample the nickname of the user "Hendrik.Faber", so Result:
"created by: Hendrik Faber"
How I can view the NICKNAME of the USER of the page on the preview of the PAGE LIST? There is no "User" and "User Nickname" setting in the page list. I need to manually paste this into php.
But how? And in which PHP file?
Thanks,
Marina (a newbie!)
I think you would need a custom pagelist template to do this.
@Marina68
If you private message me, I will put together a custom template for you..
If you private message me, I will put together a custom template for you..
Here's the code. I added comments in it to explain step by step what's happening. Hope it helps.