Skip to content

Actions and filters

Reports: 16 hooks.

Every hook here has a description in the source.

5 actions11 filters

filter

davo_report_action_delete_target_comment

Delete a reported Davo comment — a "Delete Content" admin action from the Reports queue. Comments_Initializer hooks this, same delegation pattern as davo_report_target_exists_comment/ davo_report_target_author_comment/ davo_report_target_title_comment/ davo_report_target_url_comment above: this app's own comments are a completely separate table from native wp_comments, and Reports takes no direct dependency on the Comments domain.

Parameters of davo_report_action_delete_target_comment
ParameterTypeDescription
$deletedboolWhether the comment was deleted. Default false (no domain has hooked this).
$target_idintComment ID.
add_filter
add_filter( 'davo_report_action_delete_target_comment', 'my_filter_callback', 10, 2 );

/**
 * @param bool $deleted
 * @param int $target_id
 */
function my_filter_callback( $deleted, $target_id ) {
	// Change $deleted as needed, then return it.
	return $deleted;
}

src/domains/reports/repository.php:1531

filter

davo_report_categories

Filter the full category tree returned to the frontend.

Parameters of davo_report_categories
ParameterTypeDescription
$categoriesarray<int, array<string, mixed>>Category tree.
add_filter
add_filter( 'davo_report_categories', 'my_filter_callback', 10, 1 );

/**
 * @param array<int, array<string, mixed>> $categories
 */
function my_filter_callback( $categories ) {
	// Change $categories as needed, then return it.
	return $categories;
}

src/domains/reports/helpers.php:430

action

davo_report_created

Fires after a report has been created.

Parameters of davo_report_created
ParameterTypeDescription
$report_idintNew report ID.
$user_idintReporter user ID.
$target_typestringTarget type.
$target_idintTarget ID.
$categorystringCategory slug.
add_action
add_action( 'davo_report_created', 'my_action_callback', 10, 5 );

/**
 * @param int $report_id
 * @param int $user_id
 * @param string $target_type
 * @param int $target_id
 * @param string $category
 */
function my_action_callback( $report_id, $user_id, $target_type, $target_id, $category ) {
	// Your code here.
}

src/domains/reports/repository.php:346

action

davo_report_deleted

Fires after a report is deleted.

Parameters of davo_report_deleted
ParameterTypeDescription
$report_idintDeleted report ID.
$admin_idintAdmin who deleted it.
$reporter_user_idintThe report's own reporter — captured from $existing before the row was deleted above, since the row (and so its reporter_user_id) is no longer queryable by the time this fires.
add_action
add_action( 'davo_report_deleted', 'my_action_callback', 10, 3 );

/**
 * @param int $report_id
 * @param int $admin_id
 * @param int $reporter_user_id
 */
function my_action_callback( $report_id, $admin_id, $reporter_user_id ) {
	// Your code here.
}

src/domains/reports/repository.php:1076

action

davo_report_escalated

Fires after a report is escalated.

Parameters of davo_report_escalated
ParameterTypeDescription
$report_idintReport ID.
$actor_idintWho escalated (0 = system).
$autoboolTrue when triggered automatically by risk score.
add_action
add_action( 'davo_report_escalated', 'my_action_callback', 10, 3 );

/**
 * @param int $report_id
 * @param int $actor_id
 * @param bool $auto
 */
function my_action_callback( $report_id, $actor_id, $auto ) {
	// Your code here.
}

src/domains/reports/repository.php:1245

filter

davo_report_escalation_threshold

Filters the report severity total at which a reported item is escalated. Defaults to the reports_escalation_threshold setting (30).

Parameters of davo_report_escalation_threshold
ParameterTypeDescription
$thresholdintEscalation threshold.

Returns int

add_filter
add_filter( 'davo_report_escalation_threshold', 'my_filter_callback', 10, 1 );

/**
 * @param int $threshold
 */
function my_filter_callback( $threshold ) {
	// Change $threshold as needed, then return it.
	return $threshold;
}

src/domains/reports/helpers.php:174

filter

davo_report_rest_field_object_types

Filter the WordPress REST object types the davo_reports field is attached to. Defaults to the three built-in types Reports itself understands directly.

Reports has no built-in knowledge of any other domain's custom post types by design. A domain that wants davo_reports exposed on its own custom post type's default REST response should add its post type slug via this filter from its own initializer, for example: add_filter( 'davo_report_rest_field_object_types', function ( array $types ): array { $types[] = Questions_Helpers::POST_TYPE_QUESTION; $types[] = Questions_Helpers::POST_TYPE_ANSWER; return $types; } ); Any post type added here is automatically bucketed under Reports' own TARGET_POST target type by resolve_target_type() below — Reports' target_type enum only distinguishes post/comment/user, not individual post types, since get_post() already resolves any post type generically.

Parameters of davo_report_rest_field_object_types
ParameterTypeDescription
$object_typesstring[]WordPress REST object type slugs.
add_filter
add_filter( 'davo_report_rest_field_object_types', 'my_filter_callback', 10, 1 );

/**
 * @param string[] $object_types
 */
function my_filter_callback( $object_types ) {
	// Change $object_types as needed, then return it.
	return $object_types;
}

src/domains/reports/initializer.php:312

filter

davo_report_severity_weights

Filter the risk-score weight for each report category.

Parameters of davo_report_severity_weights
ParameterTypeDescription
$weightsarray<string, int>Map of category slug → integer weight.
add_filter
add_filter( 'davo_report_severity_weights', 'my_filter_callback', 10, 1 );

/**
 * @param array<string, int> $weights
 */
function my_filter_callback( $weights ) {
	// Change $weights as needed, then return it.
	return $weights;
}

src/domains/reports/helpers.php:136

action

davo_report_status_updated

Fires after a report's status is updated.

Parameters of davo_report_status_updated
ParameterTypeDescription
$report_idintReport ID.
$old_statusstringPrevious status.
$new_statusstringNew status.
$admin_idintAdmin user ID.
$reporter_user_idintThe report's own reporter — included so a listener can address a reporter-scoped destination (e.g. a realtime channel) without a second lookup back to this row.
add_action
add_action( 'davo_report_status_updated', 'my_action_callback', 10, 5 );

/**
 * @param int $report_id
 * @param string $old_status
 * @param string $new_status
 * @param int $admin_id
 * @param int $reporter_user_id
 */
function my_action_callback( $report_id, $old_status, $new_status, $admin_id, $reporter_user_id ) {
	// Your code here.
}

src/domains/reports/repository.php:1165, and 2 more places

filter

davo_report_target_author_comment

Mirrors davo_report_target_exists_comment — lets the Comments domain (or any other non-native comment-shaped domain) resolve the author of its own comment IDs so self-report blocking works for them too. Only consulted when the native lookup above didn't resolve an author.

Parameters of davo_report_target_author_comment
ParameterTypeDescription
$author_idintAuthor user ID resolved so far (0 = unresolved).
$target_idintComment ID.
add_filter
add_filter( 'davo_report_target_author_comment', 'my_filter_callback', 10, 2 );

/**
 * @param int $author_id
 * @param int $target_id
 */
function my_filter_callback( $author_id, $target_id ) {
	// Change $author_id as needed, then return it.
	return $author_id;
}

src/domains/reports/repository.php:1761

filter

davo_report_target_exists_comment

Let other comment-shaped domains (notably this app's own Comments domain, whose davo_comments table is entirely separate from wp_comments) resolve their own IDs. See the "A NOTE ON TARGET_COMMENT" docblock on Reports_Helpers::VALID_TARGET_TYPES for the full rationale.

Parameters of davo_report_target_exists_comment
ParameterTypeDescription
$existsboolWhether a native WP comment with this ID was found.
$target_idintComment ID being validated.
add_filter
add_filter( 'davo_report_target_exists_comment', 'my_filter_callback', 10, 2 );

/**
 * @param bool $exists
 * @param int $target_id
 */
function my_filter_callback( $exists, $target_id ) {
	// Change $exists as needed, then return it.
	return $exists;
}

src/domains/reports/repository.php:1705, and 3 more places

filter

davo_report_target_title_comment

Resolve a comment's display title, for the "My Reports" page. Comments_Initializer hooks this to return e.g. a truncated excerpt of the comment content.

Parameters of davo_report_target_title_comment
ParameterTypeDescription
$defaultstringDefault title (empty string = unresolved).
$target_idintComment ID.
add_filter
add_filter( 'davo_report_target_title_comment', 'my_filter_callback', 10, 2 );

/**
 * @param string $default
 * @param int $target_id
 */
function my_filter_callback( $default, $target_id ) {
	// Change $default as needed, then return it.
	return $default;
}

src/domains/reports/repository.php:671

filter

davo_report_target_title_post

Override the resolved title for a "My Reports" row whose target is a WordPress post. Default is get_the_title(), or the "Reply to: …" fallback above when that's empty.

Parameters of davo_report_target_title_post
ParameterTypeDescription
$titlestringResolved title so far.
$post\WP_PostThe reported post.
add_filter
add_filter( 'davo_report_target_title_post', 'my_filter_callback', 10, 2 );

/**
 * @param string $title
 * @param \WP_Post $post
 */
function my_filter_callback( $title, $post ) {
	// Change $title as needed, then return it.
	return $title;
}

src/domains/reports/repository.php:637

filter

davo_report_target_url_comment

Resolve a comment's canonical URL (typically its parent question/answer's permalink plus an anchor).

Parameters of davo_report_target_url_comment
ParameterTypeDescription
$defaultstringDefault URL (empty string = unresolved).
$target_idintComment ID.
add_filter
add_filter( 'davo_report_target_url_comment', 'my_filter_callback', 10, 2 );

/**
 * @param string $default
 * @param int $target_id
 */
function my_filter_callback( $default, $target_id ) {
	// Change $default as needed, then return it.
	return $default;
}

src/domains/reports/repository.php:680

filter

davo_report_target_url_post

Override the resolved URL for a "My Reports" row whose target is a WordPress post. Default is get_permalink(), which resolves to nothing useful for a post type registered with publicly_queryable => false (e.g. this app's own answers) — a domain in that situation should hook this to point somewhere real instead.

Parameters of davo_report_target_url_post
ParameterTypeDescription
$urlstringResolved URL so far.
$post\WP_PostThe reported post.
add_filter
add_filter( 'davo_report_target_url_post', 'my_filter_callback', 10, 2 );

/**
 * @param string $url
 * @param \WP_Post $post
 */
function my_filter_callback( $url, $post ) {
	// Change $url as needed, then return it.
	return $url;
}

src/domains/reports/repository.php:650

action

davo_report_withdrawn

Fires after a reporter withdraws their own report.

Parameters of davo_report_withdrawn
ParameterTypeDescription
$report_idintWithdrawn report ID.
$user_idintReporter who withdrew it.
add_action
add_action( 'davo_report_withdrawn', 'my_action_callback', 10, 2 );

/**
 * @param int $report_id
 * @param int $user_id
 */
function my_action_callback( $report_id, $user_id ) {
	// Your code here.
}

src/domains/reports/repository.php:948

Note. Generated from the plugin source. Descriptions and parameters are the ones written in the code. The starter code uses the parameter names from those comments, or generic names where there are none, so check them against your use.

See it on your own site.

Davo is a WordPress theme and plugin by Exorex.

  • Runs on your own WordPress
  • Guided setup wizard
  • AI is off until you switch it on
  • Read the licence on the marketplace first