---
name: kimaai_loaded
type: action
since: 1.3.7
tier: free
feature: none
area: tools-addons
summary: Fires once KimaAI and its add-ons are loaded, for code that needs KimaAI active.
parameters:
  - name: main
    type: Main
    description: KimaAI's main object (KimaAI\Main).
  - name: classes
    type: ClassesSurface
    description: Access to KimaAI's services (KimaAI\Surfaces\ClassesSurface).
  - name: manager
    type: AddonManager
    description: KimaAI's add-on manager (KimaAI\Addons\AddonManager), after it started the add-ons.
---

# kimaai_loaded

## When it fires

Once per request, on `plugins_loaded` (priority 10), right after `kimaai_register_addons` and after every registered add-on's `register()` ran. KimaAI has built its services and registered its own hooks by then; WordPress's `init` has not run yet. It does not fire when KimaAI is not active, so code inside the callback runs only with KimaAI.

It suits an integration that needs no add-on class: a few hooks that only make sense with KimaAI, or classes of your plugin that use KimaAI's. Add the callback when your plugin's main file loads, not in a `plugins_loaded` callback of your own, which may run after KimaAI's.

## Example

```php
add_action(
  'kimaai_loaded',
  function (): void {
    add_filter(
      'kimaai_chatbot_instructions',
      function (string $instructions): string {
        return $instructions . "\nOur support line is open Monday to Friday, 9:00 to 17:00.";
      }
    );
  },
  10,
  0
);
```

The callback adds a line to the chatbot's instructions, and only on sites where KimaAI runs.

## More examples

`did_action('kimaai_loaded')` tells later code whether KimaAI is running, for example to ask for it in the admin:

```php
add_action(
  'admin_notices',
  function (): void {
    if (did_action('kimaai_loaded') || !current_user_can('activate_plugins')) {
      return;
    }

    echo '<div class="notice notice-warning"><p>' . esc_html__('My add-on needs KimaAI. Install and activate KimaAI to use it.', 'my-addon') . '</p></div>';
  }
);
```

## Related

- `kimaai_register_addons`: registers an add-on class, which KimaAI starts before this action.
