API version: 0.3.0

---

# `user:role:add`

Assigns a role to a user, issued by the CLI.

The `user` argument is the unique identifier of the user or its UUID. The `role` must be defined in the instance configuration. Assigning a role which the user already holds from the CLI replaces the earlier assignment. The anonymous user can not hold roles.

See [roles and capabilities](/reference/roles-and-capabilities.md) for the concept.

## Help

```bash
php bin/console user:role:add --help
```

```text
Description:
  Assigns a role to a user.

Usage:
  user:role:add <user> <role>

Arguments:
  user                  Unique identifier of the user or the user's UUID
  role                  Name of the role, which must be defined in the instance configuration

Options:
  -h, --help            Display help for the given command. When no command is given display help for the list command
      --silent          Do not output any message
  -q, --quiet           Only errors are displayed. All other output is suppressed
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -e, --env=ENV         The Environment name. [default: "prod"]
      --no-debug        Switch off debug mode.
      --profile         Enables profiling (requires debug).
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
```

## Example

```bash
php bin/console user:role:add user-role-command-test@localhost.dev admin
```

```text
    ▄
  ▄▀ ▀▄  Ember Nexus API
   ▀█▀   v0.3.0, production mode

  User Role Add

▶ Assigned role 'admin' to user 02IiNr0GPQPJbwTUIeejymdFSke4UA5UDWbij.
```

---

Home: [Ember Nexus API docs](/index.md)

Full site map: [llms.txt](/llms.txt)

Previous: [user:create](/command/user-create.md)

Next: [user:role:list](/command/user-role-list.md)
