WPBot Core hooks and functions
On this page
WPBot Core holds the services every WPBot tool shares. Its hooks start with qcld_wpbot_core/. Hooks that only connect WPBot's own modules and screens (admin design, host registration, social logins) are left out here.
Knowledge base
The knowledge base is what the chatbot and other AI features search before they answer. Posts follow edits on their own: saved, unpublished and deleted posts are updated right away, and their vectors follow in the background. WooCommerce products are synced again when their price or stock changes.
| Hook | Type | Parameters | What it is for |
|---|---|---|---|
qcld_wpbot_core/kb_post_types | filter | string[] $types | Post types the knowledge base reads (the owner's choice in AI / Settings → Knowledge Base) |
qcld_wpbot_core/kb_post_text | filter | string $text, WP_Post $post | The text stored for one post: add custom fields, product data or remove boilerplate |
qcld_wpbot_core/kb_post_access | filter | string[] $labels, WP_Post $post | Access labels of a post: public, logged_in, role:*, membership:*, course:*, purchased:*; empty = everyone |
qcld_wpbot_core/kb_sources | filter | array $sources | Add a source that is not a post type: id => [ label, count, items ] |
qcld_wpbot_core/kb_search_args | filter | array $args, string $query | Change a search before it runs: types, exclude_types, weights per source |
qcld_wpbot_core/kb_pre_search | filter | null, string $query, array $args | Return your own results to answer a search elsewhere; null searches as usual |
qcld_wpbot_core/kb_resync_meta_keys | filter | string[] $keys | Post meta keys whose change syncs the post again (default _price, _regular_price, _sale_price, _stock_status, _stock) |
qcld_wpbot_core/kb_scan_limit | filter | int $limit | Recent pieces scored by vector besides full-text hits (default 2000) |
qcld_wpbot_core/kb_item_stored | action | string $source, array $item | An item was stored with new content |
qcld_wpbot_core/kb_item_removed | action | string $source, string $id | An item left the knowledge base |
qcld_wpbot_core/kb_emptied | action | int $removed | The whole knowledge base was emptied |
Knowledge base functions
| Function | What it does |
|---|---|
qcld_wpbot_core_kb_search( $query, $args ) | Search the knowledge base. $args: top_k, min_score, types, exclude_types, weights, labels (the visitor's access labels; omitted = public only). Each result has title, url, content, score, source_type, source_id, heading_path, anchor. |
qcld_wpbot_core_kb_context( $query, $args ) | The same search as ready-to-use prompt text |
qcld_wpbot_core_kb_store( $source, $item ) | Store or update one item: id, title, url, content, optional language, access, html, modified |
qcld_wpbot_core_kb_remove( $source, $id ) | Remove one item |
qcld_wpbot_core_kb_set_access( $source, $id, $labels ) | Change who may see an item |
qcld_wpbot_core_kb_type_stats( $type ) | Items, pieces, ready, pending and errors of a source |
Examples are in Feed your own data to the chatbot's knowledge base.
AI providers and keys
| Hook | Type | Parameters | What it is for |
|---|---|---|---|
qcld_wpbot_core/ai_providers | filter | array $providers | The provider and model catalogue with prices used for cost estimates |
qcld_wpbot_core/route_model | filter | string $model, string $provider, array $context (module, feature, question) | Choose another model for one request; return the model id |
qcld_wpbot_core/fallback_provider | filter | string $fallback, string $provider, WP_Error $error, array $context | The provider id to try when a provider failed; '' for none |
qcld_wpbot_core/model_price_feed | filter | bool $on | Return false to stop the weekly download of current model prices from OpenRouter's public model list |
qcld_wpbot_core/rejected_key_ttl | filter | int $seconds | How long a key the provider rejected is not sent again (default six hours) |
qcld_wpbot_core/key_status_changed | action | string $module, string $provider, string $cause | A key started or stopped failing. $cause is one of invalid_key, no_credit, rate_limit, model_removed, no_key, key_unreadable (or empty when it works again) |
Encryption key: API keys are stored encrypted with your site's salts. Define QCLD_WPBOT_CORE_KEY in wp-config.php to use your own encryption key instead. If you change the salts or this constant later, saved keys can no longer be read and must be pasted again.
AI spending
Every AI call is checked against the owner's limits and recorded. All figures are estimates. See Set AI spending limits and alerts.
| Hook | Type | Parameters | What it is for |
|---|---|---|---|
qcld_wpbot_core/spend_recorded | action | array $row | One AI call was recorded (no prompt or answer text) |
qcld_wpbot_core/spend_limit_reached | action | $scope, $reason, $module, $feature | A limit stopped a call; once per scope and request |
qcld_wpbot_core/spend_settings_saved | action | – | The owner saved Spending and limits |
qcld_wpbot_core/spend_alert_recipients | filter | string[] $emails, array $settings | Who receives spending alerts |
qcld_wpbot_core/spend_capability | filter | string $cap | Capability for the spending screens and routes (default manage_options) |
qcld_wpbot_core/spend_prices | filter | array $prices | Prices that are not per token (images, speech, web searches) |
qcld_wpbot_core/spend_hourly | action | – | Hourly spending check |
qcld_wpbot_core/spend_weekly | action | – | Once a week, on the owner's weekday |
If your own plugin calls an AI provider on WPBot's behalf, meter it with qcld_wpbot_core_spend_allow( $module, $feature, $estimate ) (returns true or a WP_Error when a limit is reached) and qcld_wpbot_core_spend_record( $module, $feature, $usage, $meta ), or wrap the call in qcld_wpbot_core_spend_wrap( $module, $feature, $callable, $meta ).
Background jobs
Bulk work (knowledge base syncs, AI Writer batches and similar) runs as jobs on WP-Cron, every five minutes and right after a job is queued.
| Hook | Type | Parameters | What it is for |
|---|---|---|---|
qcld_wpbot_core/job_done | action | array $job | A job finished |
qcld_wpbot_core/job_handlers | filter | array $handlers | Step kind => callable, for modules that add job steps |
The WP-Cron event is qcld_wpbot_core_run_jobs. See Background jobs, digests and scheduled tasks do not run (WP-Cron).
Error log
| Hook / function | Type | Parameters | What it is for |
|---|---|---|---|
qcld_wpbot_core_log_error( $source, $message, $detail ) | function | – | Add your own entry to WPBot's error log; returns whether it was stored |
qcld_wpbot_core/error_log_enabled | filter | bool $on | Force the error log on or off, whatever the owner chose |
qcld_wpbot_core/error_log_outside | filter | bool $on | Whether errors from other plugins, the theme and WordPress are recorded |
See Error log and support reports.
Notification emails
| Hook | Type | Parameters | What it is for |
|---|---|---|---|
qcld_wpbot_core/notification_emails | filter | string[] $emails, bool $saved | The addresses WPBot's staff emails go to |
qcld_wpbot_core/notification_default_emails | filter | string[] $emails | Addresses suggested on AI / Settings → Notifications |
qcld_wpbot_core/route_notification | filter | bool $route, array $mail | Return false to keep one WPBot email out of the notification list routing |
The function qcld_wpbot_core_notification_emails() returns the current list. Emails to visitors and customers are never routed. Two more filters decide each email's timing: qcld_wpbot_notification_classify (which notification an email is) and qcld_wpbot_notification_decision (instant, daily, weekly or off). See Notification emails and digests.
Branding
qcld_wpbot_core/brand (filter, array $brand) holds the product name, logo, URL and colours that WPBot's screens show. White Label sets the same values from the admin; see White Label: your own name and logo.
Availability
In every edition, including WPBot Free. The spending report sections by channel and provider, spike alerts and the weekly summary email are added by WPBot Pro Professional and Master.
Was this article helpful?
Sorry about that. Get help another way:

