user_ID

Numerical ID of the current WordPress user is stored in this global variable. It is set when the current user is created in the pluggable functions get_currentuserinfo() defined in [wordpress root folder]/wp-includes/pluggable-functions.php.

This global variable can be used to pass as a parameter to lot of WordPress functions which require this information. It is also useful when you have to build a custom SQL query for requesting information for this user. WordPress caches the user information by the user ID, it can be retrieved using this global variable, e.g.,

$user = wp_cache_get($user_ID, 'users');

Back to full list of global variables.

Technorati tags:

One Response to “user_ID”


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: