I want to create a block which serves content based on who is viewing it. How can I tell what user is accessing it? Also, can I query/ write to my User table from a block?
I haven't found any documentation that describes the external data I can access from a block.
Thanks!
It should work to vary the block contents based on global $USER, which holds information about the currently logged-in user.
Thanks, Tim. Where can I find the class definition for $USER, and information about the other globals?
Just do
print_object($USER);
somewhere in your code, and see what you have got.
$USER is basically get_record('user', 'id', {current user id});
but with some extra bits. It is initialised in require_login, if I remember correctly.
print_object($USER);
somewhere in your code, and see what you have got.
$USER is basically get_record('user', 'id', {current user id});
but with some extra bits. It is initialised in require_login, if I remember correctly.