By sylvaticus on
hello.. often I'd like to discriminate between anonymous and logged-in users.
I saw that with the right permissions I can use php on my content and I have the feeling that there must be an API function that return the "status" of the user, so I can use it to display separate messages.
Can anyone point me to the right place? Thank you ;-)
Comments
Here is the basic PHP to determine if someone is logged in
There is no API, code just uses the global $user, something like this
thanks, works greatly
thanks, works greatly ;-)
Where can I get all the globals I can use ?
getting a list of available globals & superglobals
The easiest way I know of to get a list of all the globals is to print them out in your node or theme file using:
That will give you a formatted list of all the superglobals(all caps) and globals.
For a more detailed explanation see http://drupal.org/node/46200.
---
Brian Hiatt
Civic Pixel Ltd.
Open Media Foundation
(no title)
To save you some time, if you read past the superglobals and get to drupal's globals you won't find anything else of much interest. Most of the rest hold just a string and some are interesting only in a limited context. A grep in the core files shows:
$GLOBALS['user']
$GLOBALS['db_type']
$GLOBALS['active_db']
$GLOBALS['base_url']
$GLOBALS['base_path']
$GLOBALS['theme']
$GLOBALS['locale']
$GLOBALS['multibyte']
$GLOBALS['access_check']
$GLOBALS['pager_page_array']
$GLOBALS['pager_total']
$GLOBALS['form_values']
$GLOBALS['element']
$GLOBALS['item']
$GLOBALS['tag']
That is all. There are also some statics in some scopes.