Have get_current_user_id() return 0 when pluggable.php is not yet included (which brings the ability to set or get the current user).

fixes #25690 for trunk.


git-svn-id: https://develop.svn.wordpress.org/trunk@25929 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2013-10-26 03:19:41 +00:00
parent 350c015f94
commit eba5ddbcfa
1 changed files with 2 additions and 0 deletions

View File

@ -212,6 +212,8 @@ function count_many_users_posts( $users, $post_type = 'post', $public_only = fal
* @return int The current user's ID * @return int The current user's ID
*/ */
function get_current_user_id() { function get_current_user_id() {
if ( ! function_exists( 'wp_get_current_user' ) )
return 0;
$user = wp_get_current_user(); $user = wp_get_current_user();
return ( isset( $user->ID ) ? (int) $user->ID : 0 ); return ( isset( $user->ID ) ? (int) $user->ID : 0 );
} }