How do I obtain UserID within a Block?

Permalink
I'm trying to make life easy for my users... perhaps I'm over complicating it and there's an easier way - I'm open to that possibility and if somebody can help me see the light, many thanks!

I'm adding to Tony's Login block so that once logged in, it will hide the login form, display a link to logout, and display a "Change Password" link. I have that password change link pointing to the following:
"/index.php/dashboard/users/search?uID=' . $uID . '&task=edit"


I've looked at the API and found
User::getUserID();

but that doesn't do what I expect it to when I
$uID=User::getUserID();


Most of the time, when I run into these kinds of issues, I'm forgetting something silly and it just takes another pair of eyes ...

 
bpysher replied on at Permalink Reply
Sorry, I forgot to mention what I see when I use the above mentioned code... nothing.

I echo out my variable, and it appears to be blank.
Maynar replied on at Permalink Best Answer Reply
Maynar
$u = new User();
echo $u->uID;


When a user is logged in it will get the logged in user with new User();. when $u->uID is empty the user is not logged in. Or use:

$u = new User();
if($u->isLoggedIn()==true)
{
//Logged in: Action
}