WebSite X5Help Center

 
Capon P.
Capon P.
User

Variable with the 'logged in' user  en

Author: Capon P.
Visited 2619, Followers 3, Shared 0  

Hello, can I get a (php)variable with the 'logged in' user in order to add it to a mysql database for logging purposes?

My scenario: a user logs in to protected area. The moment (s)he clicks on a downloadlink the username + clicked link is written to a mysql databas 

Thanks for your suggestions

Posted on the
3 ANSWERS - 1 USEFUL - 1 CORRECT
Incomedia
Claudio D.
Incomedia

Hello Capon,

Unfortunately I cannot help you with the use of custom code, but if you have any doubts or issues on how to add them in the pages you made with WebSite X5 youcan ask me anytime.

To get the variable of the logged username you can use following code:

<?php

$pa = new imPrivateArea();

$user = $pa->who_is_logged();

echo $user['username'];

?>

Please feel free to write back if you need more information.

Read more
Posted on the from Claudio D.
Capon P.
Capon P.
User
Author

Hi Claudio, this works perfectly!

Are User/Group - Remark / Password (from login management) also stored in a variable and can I get these in a way? Is the there a description all used php-variables? I could use this for future projects.

thanks for the quick anc clear responses.  I really like the software and will be making some suggestions for extra functionality.

Read more
Posted on the from Capon P.
Incomedia
Claudio D.
Incomedia

Hello Capon,

The other variables you can use are the following instead of ['username']:

  • $user['uid'] where you get the User ID.
  • $user['realname'] where you get the real name.

These other fields unfortunately cannot be accessed form the variables.

Many thanks!

Read more
Posted on the from Claudio D.