# Reactions::register_object_type()

Register a reactable object type.

```php
register_object_type( string $object_type, array $args ): bool
```

## Parameters

- `$object_type` (string) Lowercase slug (`a-z0-9_-`), unique per kind of thing, e.g. `forum_topic`.
- `$args` (array<string, mixed>) Definition.
  - `$label` (string) Readable name.
  - `$toggle` (callable) `( int $id, int $user_id, string $slug ): array` stores the reaction and returns the new state (`active`, `reaction_type`, `reactions_count`, `reactions_by_type`, `user_reactions`). Required.
  - `$exists` (callable) `( int $id ): bool` whether the object exists. Optional (default: assume it does).
  - `$can_react` (callable) `( int $id, int $user_id, string $slug ): bool|WP_Error` whether this user may react. Return a `WP_Error` to explain a refusal. Optional (default: any signed-in user).
  - `$can_view` (callable) `( int $id, int $user_id ): bool|WP_Error` whether this user may see the object, so the "See all" list of who reacted is only given to people who can see it. Optional (default: anyone).
  - `$enabled` (callable) `(): bool` whether this kind of object currently allows reactions (a settings switch). Optional (default: Social Kit's "Social reactions" setting).
  - `$reactors` (callable) `( int $id, int $per_slug ): array` who reacted, as `slug => list<user id>`, for the reactor stacks in tooltips. Optional (default: none shown).
  - `$author` (callable) `( int $user_id ): array` how a reactor is described to the browser (`id`, `name`, `profile_url`, `avatar_url`…). Optional (default: `Reactions::default_author()`).
  - `$types` (callable) `(): array` reaction types usable on this object. Optional (default: the shared registry, `Reaction_Registry::get_types()`).
  - `$key_prefix` (string) Prefix of the tooltip key the UI uses per reaction (`{prefix}{id}-{slug}`), unique per type on one page, e.g. `t` for forum topics. Optional.

## Return

`bool` True when registered.

## Changelog

| Version | Description |
| --- | --- |
| 1.6.4 | Updated |
| 1.6.2 | Introduced |
