A WordPress-centric search engine for devs and theme authors



get_current_user_id ›

Since3.0.0
Deprecatedn/a
get_current_user_id ( No parameters )
Returns:
  • (int) The current user's ID, or 0 if no user is logged in.
Defined at:
Codex:
Change Log:
  • MU

Get the current user's ID



Source

function get_current_user_id() {
	if ( ! function_exists( 'wp_get_current_user' ) )
		return 0;
	$user = wp_get_current_user();
	return ( isset( $user->ID ) ? (int) $user->ID : 0 );
}