Skip to content

Actions and filters

Comments: 11 hooks.

Every hook here has a description in the source.

6 actions5 filters

action

davo_comment_created

Fires after a comment is successfully created.

Parameters of davo_comment_created
ParameterTypeDescription
$comment_idintNew comment ID.
$target_typestringTarget type slug.
$target_idintTarget content ID.
$user_idintAuthor user ID.
add_action
add_action( 'davo_comment_created', 'my_action_callback', 10, 4 );

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

src/domains/comments/repository.php:304

action

davo_comment_deleted

Fires after a comment is soft-deleted.

Parameters of davo_comment_deleted
ParameterTypeDescription
$comment_idintDeleted comment ID.
$target_typestringTarget type slug the comment belonged to.
$target_idintTarget content ID.
$user_idintUser who deleted it.
add_action
add_action( 'davo_comment_deleted', 'my_action_callback', 10, 4 );

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

src/domains/comments/repository.php:460

filter

davo_comment_response

Filters the response array for a single comment.

Parameters of davo_comment_response
ParameterTypeDescription
$responsearray<string, mixed>The comment as returned by the API.

Returns array<string, mixed>

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

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

src/domains/comments/helpers.php:402, and 1 more place

action

davo_comment_restored

Fires after a moderator restores a soft-deleted comment.

Parameters of davo_comment_restored
ParameterTypeDescription
$comment_idintRestored comment ID.
$target_typestringTarget type the comment belongs to.
$target_idintTarget ID the comment belongs to.
$user_idintModerator who performed the restore.
add_action
add_action( 'davo_comment_restored', 'my_action_callback', 10, 4 );

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

src/domains/comments/repository.php:769

action

davo_comment_updated

Fires after a comment is updated.

Parameters of davo_comment_updated
ParameterTypeDescription
$comment_idintComment ID.
$editor_idintUser who made the edit.
add_action
add_action( 'davo_comment_updated', 'my_action_callback', 10, 2 );

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

src/domains/comments/repository.php:392

action

davo_comment_vote_removed

Fires after a comment vote is explicitly removed.

Parameters of davo_comment_vote_removed
ParameterTypeDescription
$comment_idintComment ID.
$user_idintVoter user ID.
$old_voteintVote value that was removed.
add_action
add_action( 'davo_comment_vote_removed', 'my_action_callback', 10, 3 );

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

src/domains/comments/repository.php:1025

action

davo_comment_voted

Fires after a comment vote is cast, changed, or removed.

Parameters of davo_comment_voted
ParameterTypeDescription
$comment_idintComment ID.
$user_idintVoter user ID.
$author_idintComment author user ID.
$new_voteintNew vote value (0 = removed).
$old_voteintPrevious vote value (0 = none existed).
add_action
add_action( 'davo_comment_voted', 'my_action_callback', 10, 5 );

/**
 * @param int $comment_id
 * @param int $user_id
 * @param int $author_id
 * @param int $new_vote
 * @param int $old_vote
 */
function my_action_callback( $comment_id, $user_id, $author_id, $new_vote, $old_vote ) {
	// Your code here.
}

src/domains/comments/repository.php:971

filter

davo_comments_masked_avatar_url

Filters the URL of the avatar shown in place of a masked comment author. Defaults to a generic person icon.

Parameters of davo_comments_masked_avatar_url
ParameterTypeDescription
$urlstringAvatar image URL.

Returns string

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

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

src/domains/comments/helpers.php:285

filter

davo_comments_migration_target_namespace

Filters the migration namespace used for a comment target type that does not declare one. Defaults to wp_post.

Parameters of davo_comments_migration_target_namespace
ParameterTypeDescription
$namespacestringMigration namespace.
$target_typestringComment target type slug.

Returns string

add_filter
add_filter( 'davo_comments_migration_target_namespace', 'my_filter_callback', 10, 2 );

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

src/domains/comments/migration-provider.php:694

filter

davo_comments_target_types

Filters the registered comment target types, the kinds of item that can have comments. Each domain adds its own.

Parameters of davo_comments_target_types
ParameterTypeDescription
$typesarray<string, array<string, callable|string>>Target type slug => configuration. Empty by default.

Returns array<string, array<string, callable|string>>

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

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

src/domains/comments/helpers.php:43

filter

davo_rate_limit_check

Filters a rate-limit check. Return true to allow the action or a WP_Error to block it. Comments use it for flood control.

Parameters of davo_rate_limit_check
ParameterTypeDescription
$resulttrue|\WP_ErrorDefaults to true when no throttle is active.
$actionstringThe action being checked, such as create_comment.
$user_idintThe acting user's ID.

Returns true|\WP_Error

add_filter
add_filter( 'davo_rate_limit_check', 'my_filter_callback', 10, 3 );

/**
 * @param true|\WP_Error $result
 * @param string $action
 * @param int $user_id
 */
function my_filter_callback( $result, $action, $user_id ) {
	// Change $result as needed, then return it.
	return $result;
}

src/domains/comments/repository.php:240

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