$user = UserService::getCurrentUser();if (isset($user) && UserService::isCurrentUserAdmin()) { return 'Welcome administrator.';}return 'You are not an administrator.';
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[[["\u003cp\u003eApplications can check if the currently signed-in user has administrator privileges.\u003c/p\u003e\n"],["\u003cp\u003eAdministrators have access to the application's Administration Console for management tasks.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eUserService::isCurrentUserAdmin()\u003c/code\u003e function determines if the current user is an administrator, returning \u003ccode\u003eTrue\u003c/code\u003e if they are.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003elogin: admin\u003c/code\u003e configuration element can restrict access to parts of an application, limiting it to administrators.\u003c/p\u003e\n"]]],[],null,["# Admin Users\n\nAn application can test whether the currently signed-in user is a registered administrator for the application. An administrator is a user who can access [the Administration Console](/appengine/docs/adminconsole) for the application. You can use the Administration Console to manage which users have administrator status.\n| This page describes how to use the legacy bundled services and APIs. This API can only run in first-generation runtimes in the App Engine standard environment. If you are updating to the App Engine PHP 7/8 runtime, refer to the [migration guide](/appengine/migration-center/standard/migrate-to-second-gen/php-differences) to learn about your migration options for legacy bundled services.\n\nThe function UserService::isCurrentUserAdmin() returns `True` if the current user is an administrator for the application. \n\n use google\\appengine\\api\\users\\User;\n\n $user = UserService::getCurrentUser();\n if (isset($user) && UserService::isCurrentUserAdmin()) {\n return 'Welcome administrator.';\n }\n return 'You are not an administrator.';\n\n**Tip:** An easy way to restrict access to a part of your application to administrators is to use the `login: admin` configuration element for the URL handler. See [Configuring an App](/appengine/docs/legacy/standard/php/config/appref)."]]