API: New function to fetch current user id
This commit is contained in:
@@ -91,6 +91,22 @@ class BaseApi extends BaseModule
|
||||
return (bool)self::$current_user_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current user id, returns 0 if not logged in
|
||||
*
|
||||
* @return int User ID
|
||||
*/
|
||||
protected static function getCurrentUserID()
|
||||
{
|
||||
if (is_null(self::$current_user_id)) {
|
||||
api_login(DI::app(), false);
|
||||
|
||||
self::$current_user_id = api_user();
|
||||
}
|
||||
|
||||
return (int)self::$current_user_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user info array.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user