diff --git a/docs/api/public_php_api_managing_content.md b/docs/api/public_php_api_managing_content.md index 25be99a661..e4bfb58b6b 100644 --- a/docs/api/public_php_api_managing_content.md +++ b/docs/api/public_php_api_managing_content.md @@ -14,6 +14,22 @@ $user = $userService->loadUserByCredentials( $username, $password ); $permissionResolver->setCurrentUserReference($user); ``` +!!! tip "Using `sudo()`" + + To skip permission checks, you can use the `sudo()` method. + It allows API execution to be performed with full access, sand-boxed. + + You can use this method to perform an action that the current user does not have permissions for. + This option is recommended instead of setting the admin user as the current user. + + For example, to [hide a Location](public_php_api_locations.md#hideunhide-location), use: + + ``` php + $hiddenLocation = $repository->sudo(function ($repository) use ($location) { + return $repository->getLocationService()->hideLocation($location); + }); + ``` + ## Creating content !!! note "Full code"