Skip to content

Actions and filters

Realtime: 8 hooks.

Every hook here has a description in the source.

0 actions8 filters

filter

davo_realtime_can_subscribe

Filters whether a viewer may subscribe to a realtime channel.

Parameters of davo_realtime_can_subscribe
ParameterTypeDescription
$can_subscribeboolDefault false (fail closed).
$channel_typestringChannel type, e.g. 'question'.
$object_idintThe channel's object id.
$viewer_idintWordPress user id (0 = guest).
add_filter
add_filter( 'davo_realtime_can_subscribe', 'my_filter_callback', 10, 4 );

/**
 * @param bool $can_subscribe
 * @param string $channel_type
 * @param int $object_id
 * @param int $viewer_id
 */
function my_filter_callback( $can_subscribe, $channel_type, $object_id, $viewer_id ) {
	// Change $can_subscribe as needed, then return it.
	return $can_subscribe;
}

src/domains/realtime/repository.php:217

filter

davo_realtime_channel_for_target

Filters the realtime channel a comment target belongs to.

Parameters of davo_realtime_channel_for_target
ParameterTypeDescription
$channelstring|nullResolved channel so far, or null.
$target_typestringComment target type, e.g. 'question', 'answer'.
$target_idintThe target's id.
add_filter
add_filter( 'davo_realtime_channel_for_target', 'my_filter_callback', 10, 3 );

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

src/domains/realtime/listeners/comments-listener.php:197

filter

davo_realtime_fallback_poll_seconds

Filters how many seconds a client waits before polling again when it falls back from streaming. Defaults to 15.

Parameters of davo_realtime_fallback_poll_seconds
ParameterTypeDescription
$secondsintSeconds until the next poll.

Returns int

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

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

src/domains/realtime/sse.php:181

filter

davo_realtime_hide_actor

Filters whether the acting user's ID is kept out of the broadcast payload.

The payload is delivered to every subscriber of the channel, so an actor ID in it tells all of them who performed the action — which defeats anonymous posting when the actor is the author of anonymous content. When true, the payload carries actor_id 0 and the real ID is kept only in the event's own database column; get_events_since() hands it back to that one user, so a client can still recognise its own actions.

Parameters of davo_realtime_hide_actor
ParameterTypeDescription
$hideboolWhether to hide the actor. Default false.
$channelstringChannel identifier, e.g. 'question:123'.
$argsarray<string, mixed>The publish() arguments.
add_filter
add_filter( 'davo_realtime_hide_actor', 'my_filter_callback', 10, 3 );

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

src/domains/realtime/repository.php:81

filter

davo_realtime_max_connection_seconds

Filters how long, in seconds, a live stream may stay open. Defaults to 55; the value is kept between 10 and 55.

Parameters of davo_realtime_max_connection_seconds
ParameterTypeDescription
$secondsintMaximum stream lifetime in seconds.

Returns int

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

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

src/domains/realtime/helpers.php:217

filter

davo_realtime_max_connections_per_guest_ip

Filters how many live streams one anonymous visitor (by IP address) may hold open. Defaults to 3.

Parameters of davo_realtime_max_connections_per_guest_ip
ParameterTypeDescription
$limitintMaximum concurrent streams.

Returns int

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

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

src/domains/realtime/helpers.php:129

filter

davo_realtime_presence_can_subscribe

Filters whether a viewer may subscribe to the presence channel.

Parameters of davo_realtime_presence_can_subscribe
ParameterTypeDescription
$allowedboolDefault: any signed-in user, and only on the site-wide channel.
$viewer_idintWordPress user ID.
add_filter
add_filter( 'davo_realtime_presence_can_subscribe', 'my_filter_callback', 10, 2 );

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

src/domains/realtime/listeners/user-status-listener.php:86

filter

davo_realtime_publish_presence

Filters whether a presence change is published.

Parameters of davo_realtime_publish_presence
ParameterTypeDescription
$publishboolWhether to publish. Default true.
$user_idintUser whose status changed.
$idleboolWhether the user was marked idle.
add_filter
add_filter( 'davo_realtime_publish_presence', 'my_filter_callback', 10, 3 );

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

src/domains/realtime/listeners/user-status-listener.php:115

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