WordPress.org

Ready to get started?Download WordPress

Codex

Function Reference/get current user id

Contents

Description

Returns the ID of the current user.

Usage

 <?php $user_ID get_current_user_id(); ?> 

Returns

(int) 
The user's ID, if there is a current user; otherwise 0.

Changelog

Since: Version 3.0

Source Code

get_current_user_id() is located in wp-includes/user.php.

Related

Get User Functions:

Current User Functions: get_current_user_id(), get_currentuserinfo(), wp_get_current_user(), wp_set_current_user(), current_user_can(), current_user_can_for_blog()

See also index of Function Reference and index of Template Tags.