Skip to content

Actions and filters

Mentions: 5 hooks.

Every hook here has a description in the source.

1 action4 filters

action

davo_mention_created

Fires once per newly-mentioned user in a piece of content.

Listeners are expected to translate $target_type into their own notification type and send it via Utils::send_notification(). Mentions itself never calls Utils::send_notification — it has no opinion on notification copy or type slugs per content type.

Parameters of davo_mention_created
ParameterTypeDescription
$mentioned_user_idintUser who was mentioned.
$mentioner_idintUser who wrote the mention.
$target_typestringCaller-defined target type slug.
$target_idintID of the content mentioned in.
$target_urlstringURL to the content.
$target_excerptstringShort excerpt for notification copy.
add_action
add_action( 'davo_mention_created', 'my_action_callback', 10, 6 );

/**
 * @param int $mentioned_user_id
 * @param int $mentioner_id
 * @param string $target_type
 * @param int $target_id
 * @param string $target_url
 * @param string $target_excerpt
 */
function my_action_callback( $mentioned_user_id, $mentioner_id, $target_type, $target_id, $target_url, $target_excerpt ) {
	// Your code here.
}

src/domains/mentions/repository.php:113

filter

davo_mentions_migration_target_namespace

Filter the reference namespace a mention's target_type resolves against during migration, for a target_type this provider doesn't specifically recognize ('question'/'answer'/'comment' are handled directly).

Parameters of davo_mentions_migration_target_namespace
ParameterTypeDescription
$namespacestringDefault namespace (wp_post).
$target_typestringThe unrecognized target_type value.
add_filter
add_filter( 'davo_mentions_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/mentions/migration-provider.php:411

filter

davo_mentions_profile_url

Filter the profile URL used when rendering a resolved @mention.

Return a non-empty string to override the default WP author archive URL — e.g. if the Profile domain maintains its own slug/URL scheme separate from user_nicename permalinks.

Parameters of davo_mentions_profile_url
ParameterTypeDescription
$urlstringDefault profile URL (WP author archive).
$userWP_UserThe resolved user being linked to.
add_filter
add_filter( 'davo_mentions_profile_url', 'my_filter_callback', 10, 2 );

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

src/domains/mentions/helpers.php:404

filter

davo_mentions_resolve_handle

Filter the user resolved for a given @mention handle.

Return a WP_User to resolve the handle; return null (default) to let a later-priority filter or the built-in fallback handle it.

Parameters of davo_mentions_resolve_handle
ParameterTypeDescription
$userWP_User|nullCurrently resolved user, or null.
$handlestringThe raw handle string (no leading '@').
add_filter
add_filter( 'davo_mentions_resolve_handle', 'my_filter_callback', 10, 2 );

/**
 * @param WP_User|null $user
 * @param string $handle
 */
function my_filter_callback( $user, $handle ) {
	// Change $user as needed, then return it.
	return $user;
}

src/domains/mentions/helpers.php:222

filter

davo_mentions_search_users

Filter autocomplete search results for a partial @mention query.

Return a non-null array to short-circuit the default search with domain-specific results (e.g. matching against a profile slug table instead of user_nicename). Each entry must have the shape array{ id: int, handle: string, display_name: string, avatar_url: string }.

Parameters of davo_mentions_search_users
ParameterTypeDescription
$resultsarray<array<string,mixed>>|nullCurrently resolved results, or null.
$querystringPartial handle text.
$limitintMaximum results requested.
add_filter
add_filter( 'davo_mentions_search_users', 'my_filter_callback', 10, 3 );

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

src/domains/mentions/helpers.php:281

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