SDK
SDK PHP v3.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

createRestrictedUser #

Create a new restricted user in Kuzzle. This function allows anonymous users to create a "restricted" user with predefined rights.

There is a small delay between user creation and its availability in our search layer (usually a couple of seconds). That means that a user that was just created may not be returned immediately by the searchUsers function.


createRestrictedUser(id, content, [options], [callback]) #

ArgumentsTypeDescription
idstringUnique user identifier, will be used as username
contentJSON ObjectA plain JSON object representing the user
optionsstring(Optional) Optional arguments
callbackfunctionCallback handling the response

Options #

FilterTypeDescriptionDefault
queuablebooleanMake this request queuable or nottrue
refreshstringIf set to wait_for, Kuzzle will wait the persistence layer indexation to return (available with Elasticsearch 5.x and above)undefined

Callback response #

Resolves to a User object.

Usage #

<?php
use \Kuzzle\Kuzzle;
use \Kuzzle\Security\User;
$kuid = 'myUser';
$userDefinition = [
  'content' => [
  ],
  'credentials' => [
    'local' => [
      // The "local" authentication strategy requires a password
      'password' => 'secretPassword',
      'lastLoggedIn' => 1494411803
    ]
    ]
  ];
$kuzzle = new Kuzzle('localhost');
$security = $kuzzle->security();
try {
  $user = $security->createRestrictedUser($kuid, $userDefinition);
  // $user instanceof User
}
catch (ErrorException $e) {
}