DocsDevelopers

Hooks and filters

WordPress actions and filters for forms, data sources, dynamic data, Query Loops, analytics, reports, features, the agent and the builder.

Forms#

HookTypeArguments and use
nativeai_register_form_actionsactionRegister form actions with register_form_action().
nativeai_register_form_integrationsactionRegister integrations with register_form_integration().
nativeai_form_submissionfilter$submission — change or check a submission before it’s stored and actions run. Return a WP_Error to reject it with a message.
nativeai_form_submittedaction$submission — submitted, stored (when the form stores submissions) and its immediate actions ran.
nativeai_form_succeededaction$submission — accepted: stored and its immediate actions succeeded.
nativeai_form_failedaction$submission, $message — an action failed; $message is what the visitor was told.
nativeai_form_action_resultaction$result, $action, $submission — after each action runs.
nativeai_forms_allow_private_urlsfilterfalse, $url — let form requests reach private or local addresses.
add_filter( 'nativeai_form_submission', function ( $submission ) {
	// Reject submissions from a blocked domain.
	$email = (string) $submission->value( 'email' );
	if ( str_ends_with( strtolower( $email ), '@example.com' ) ) {
		return new WP_Error( 'blocked', 'Please use your work email.' );
	}
	return $submission;
} );

Data sources#

HookTypeArguments and use
nativeai_data_allow_private_urlsfilterfalse, $url — let data sources call private or local addresses.
nativeai_data_rate_limitfilter$per_minute, $source_id — requests per minute for a source.
nativeai_data_max_bytesfilter$bytes — the largest response accepted.

Dynamic data and Query Loops#

HookTypeArguments and use
nativeai_dynamic_meta_allowedfilter$allowed, $key, $type — expose or hide a custom field in dynamic data.
nativeai_query_argsfilter$args, $spec, $context — adjust the WordPress query arguments of Query Loops.
nativeai_query_post_typesfilter$types — the post types visitors may see in loops (public ones by default).

Analytics#

HookTypeArguments and use
nativeai_analytics_should_trackfiltertrue — return false to not count the current request.
nativeai_analytics_eventfilter$row — change an event before it’s stored; return something that isn’t an array to drop it.
nativeai_analytics_consent_requiredfilterfalse — require consent before counting, like “Wait for consent”.
nativeai_analytics_trackaction$name, $props — record a server-side event in the current visit: do_action( 'nativeai_analytics_track', 'signup', array( 'label' => 'Pro plan', 'value' => 49 ) );
nativeai_analytics_conversionaction$goal, $event — a goal was reached.

Reports and the activity record#

HookTypeArguments and use
nativeai_report_providersactionRegister report sections: Reports\Registry::register( new MyProvider() ).
nativeai_report_error_typesfilter$types — the event types the Errors section groups.
nativeai_report_summary_modelfilter'' — the model that writes report summaries.
nativeai_report_summary_prefilternull, $facts — return a summary to skip the AI call.

Add your own events to the activity record — they appear in reports, the Activity screen and the AI’s answers:

\NativeAI\Platform\Events::record( array(
	'type'        => 'backup.completed',
	'module'      => 'backups',
	'severity'    => 'info',
	'summary'     => 'Backup completed (2.4 GB)',
	'object_type' => 'backup',
	'object_id'   => '42',
) );

For repeated events, pass a fingerprint (Events::fingerprint( $type, … ) ignores IDs and numbers) and merge (seconds) so repeats fold into one line.

Features, jobs, notifications and the agent#

HookTypeArguments and use
nativeai_register_featuresactionRegister optional features.
nativeai_feature_availablefiltertrue, $feature_id, $tier — whether a feature can be switched on.
nativeai_feature_toggledaction$feature_id, $on — a feature was switched on or off.
nativeai_agent_capabilitiesactionRegister capabilities the AI agent can use (see the capability reference).
nativeai_job_failedaction$job, $error — a background job ran out of attempts.
nativeai_notification_deliveredaction$notification — send Native AI notifications elsewhere (Slack, a webhook).

Builder and rendering#

HookTypeArguments and use
nativeai_editor_head, nativeai_editor_footeractionPrint into the builder’s head and footer.
nativeai_committedaction$result — the builder saved changes.
nativeai_render_elementfilternull, $node, $context — HTML for an element type Native AI doesn’t know; return null to render nothing.