SocialEngine Tutorial – Getting the current user’s id and data

When you load any view inside your website you should always have an object named $viewer().
Here are some useful things you can find out in your view using the viewer object;

Get the current viewier’s Id


Get the current viewier’s name


Get the current viewier’s profile URL


Check if current user is an admin (return is either 1 or 0, true or false)


If you want to be able to do the same thing within your controller rather than your view you can also use

Get current viewer’s identity


On a side note if you ever need to know whats being loaded in your view just print_r out the view object. However I find it extremely useful to call get_class_methods() on the object so that you can see what you can do with it;

echo '<pre>';
echo '


(get rid of the backslash, had to include it to stop my pre tags messing up!