Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
É possível testar se o usuário conectado é um administrador registrado do aplicativo. Um administrador é um usuário que pode acessar o console de administração do aplicativo. Você pode usar o console de administração para gerenciar quais usuários têm status de administrador.
A função UserService::isCurrentUserAdmin() retorna True se o usuário atual for um administrador do aplicativo.
use google\appengine\api\users\User;
$user = UserService::getCurrentUser();if (isset($user) && UserService::isCurrentUserAdmin()) { return 'Welcome administrator.';}return 'You are not an administrator.';
Dica: um modo fácil de restringir o acesso a uma parte do aplicativo para administradores é usar o elemento de configuração login: admin do manipulador de URL. Consulte Como configurar um aplicativo.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-19 UTC."],[[["\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)."]]