Authentication

Permalink
I would like to create a custom script for a client to bolt into Concrete.

How can I extract a username of the logged on user?

For example I want my users to login to concrete to authenticate, but then I want to use their username in my script.

What is the code that give you the logged on username?

Many thanks

Ashley

 
ScottC replied on at Permalink Reply
ScottC
$u = new User();

$uName = $u->getUserName();

I don't have the code open it is late and i may be chastised in the morning for this, but I think that is what you need.
ashleyh81 replied on at Permalink Reply
So in PHP the variable $uName whould be the value of their logged in username in Concrete5?

ie echo $uName would output their username?

Many thanks
ScottC replied on at Permalink Reply
ScottC
yes :) you would echo the $uName assuming that code works, or you could just
$u = new User();
echo($u->getUserName());

If this is used once and only for that purpose (to show the logged in user's name) there isn't a need to create another variable.

If we need to re-use it we would put it in a variable to save us some typing and spare out server resources possible redundant identical objects.