WebSite X5Help Center

 
Amjad I.
Amjad I.
User

Any Way to Retrieve username When Logged In  en

Author: Amjad I.
Visited 592, Followers 2, Shared 0  

Hi everyone,

I used the Login/Logout Plugin and I can see the user's name on the header when he logs in. Does Incomedia has any feature that allows to retrieve the user's name and use it in your code?

Thanks

Posted on the
2 ANSWERS - 1 CORRECT
Axel  
Axel  
User

Hello,

yes you can.

Add an HTML object into your page. Change the html extension of this page by .php extension into page properties. During page creation you need to marlk this page as private

Add this code into your HTML object


<?php
$pa = Configuration::getPrivateArea();
$user = $pa->whoIsLogged();
echo "Bienvenue [realname]: ".$user['realname'];
?>
<br> </br>

<?php
$pa = Configuration::getPrivateArea();
$user = $pa->whoIsLogged();
echo "Bienvenue [username]: ".$user['username'];
?>
<br> </br>

<?php
$pa = Configuration::getPrivateArea();
$user = $pa->whoIsLogged();
echo "Bienvenue [uid]: ".$user['uid'];
?>
<br> </br>

<?php
$pa = new imPrivateArea();
$user = $pa->who_is_logged();
echo "Bienvenue [username] ".$user['username'];
?>
<br> </br>

<?php
$pa = new imPrivateArea();
$user = $pa->who_is_logged();
echo "Bienvenue [email] ".$user['email'];
?>
<br> </br>

<?php
$pa = new imPrivateArea();
$user = $pa->who_is_logged();
echo "Bienvenue [firstname] ".$user['firstname'];
?>
<br> </br>

<?php
$pa = new imPrivateArea();
$user = $pa->who_is_logged();
echo "Bienvenue [lastname] ".$user['lastname'];
?>

And the displaying will be.

Check on my demo : https://wsx5demo.afsoftware.fr/

TAKE CARE: You need to be logged to see the values !

Hope this helps

Axel

Read more
Posted on the from Axel  
Amjad I.
Amjad I.
User
Author

That was super helpful. Thank you very much.

Read more
Posted on the from Amjad I.