Contents
On this page

Hooks - Plugixa Video

This page is for developers. The plugin fires WordPress actions and filters, all prefixed plugixa_video_, that you can use from a theme’s functions.php or a small plugin of your own. Hooks marked PRO fire only when Pro is installed and the app that owns them is switched on.

The plugin also has hooks its own modules use to talk to each other. Only the ones below are meant for site developers; the others are listed at the end and may change between versions.

Reacting to events

Videos and media

Action Arguments When it fires
plugixa_video_video_saved $video_id After a video was created or changed through the admin app or the API.
plugixa_video_source_uploaded PRO $video_id, $source, $probe When an uploaded file has arrived and been read. $source is its full path; $probe holds width, height, duration and the audio streams.
plugixa_video_rendition_done PRO $video_id, $height, $status When one quality (such as 720) has finished converting. $status is ready or failed.
plugixa_video_ai_subtitles_done PRO $video_id, $job When AI subtitles were written for a video.
plugixa_video_import_finished PRO $job_id, $counts When an import job has handled every video. $counts holds done, failed and skipped.
add_action( 'plugixa_video_rendition_done', function ( int $video_id, int $height, string $status ) {
	if ( 'failed' === $status ) {
		wp_mail( get_option( 'admin_email' ), 'Conversion failed', get_the_title( $video_id ) . " ({$height}p)" );
	}
}, 10, 3 );

Viewers

Action Arguments When it fires
plugixa_video_video_completed $user_id, $video_id When a signed-in viewer’s saved position counts the video as watched. It may fire again on later saves, so make your code safe to run twice.
add_action( 'plugixa_video_video_completed', function ( int $user_id, int $video_id ) {
	// Remember it once, for a course progress badge.
	add_user_meta( $user_id, 'my_finished_video', $video_id );
}, 10, 2 );

Sales PRO

Action Arguments When it fires
plugixa_video_order_paid $order Once, when an order is paid. $order is the order as it was before payment.
plugixa_video_payment_recorded $payment, $order Once per payment in the ledger: first payments and renewals.
plugixa_video_renewal_failed $order, $event Once per failed renewal charge. $event has retry_at (Unix time, 0 for none) and pay_url.
plugixa_video_order_revoked $order When an order’s access is taken back: refund, dispute or membership ended.

The plugin itself

Action Arguments When it fires
plugixa_video_loaded $container Once the plugin is fully started.
plugixa_video_activated After activation, once its tables exist.
plugixa_video_deactivated On deactivation. Modules clear their scheduled jobs here.
plugixa_video_uninstall Before data is erased on delete, with erasing switched on. Fires only if the plugin happens to be loaded at that moment.
plugixa_video_settings_saved $settings After the settings were saved.
plugixa_video_app_toggled $id, $enabled After an app was switched on or off in the App manager.
plugixa_video_register_rest_routes $namespace, $container While the plugin registers its REST routes. See REST API.
plugixa_video_admin_submenus $parent_slug, $render While the admin menu is built: add your own submenu under Plugixa Video.
plugixa_video_enqueue_assets $hook_suffix After the admin app’s scripts are enqueued.
plugixa_video_public_assets $config_handle After the player’s scripts are enqueued on a public page: enqueue your own here.

Changing behavior

Who may watch

Filter Arguments What it changes
plugixa_video_user_can_view $decision, $user_id, $video_id, $mode Whether a user may watch a video. $mode is free, members or paid; $user_id is 0 for guests. The one place every access decision goes through.
plugixa_video_access_modes $modes The access choices offered in the video form. A mode should be added only by code that can also grant it.
plugixa_video_signed_url_ttl $ttl, $video_id How long a signed video link stays valid, in seconds. Default 300, never below 30.
plugixa_video_user_can $allowed, $action, $entity_type, $record, $user_id Whether a user may read, create, edit or delete a record in the back office.
plugixa_video_capabilities $map The permission flags handed to the admin app.

Members-only videos are open to any signed-in user. To limit them to a role of your own:

add_filter( 'plugixa_video_user_can_view', function ( bool $decision, int $user_id, int $video_id, string $mode ) {
	if ( 'members' !== $mode || ! $decision || user_can( $user_id, 'edit_post', $video_id ) ) {
		return $decision;
	}
	return user_can( $user_id, 'my_club_member' );
}, 10, 4 );

Player and pages

Filter Arguments What it changes
plugixa_video_player_config $config The settings handed to the public player.
plugixa_video_player_overlay $overlay, $video_id HTML placed over the player. It passes through wp_kses_post().
plugixa_video_page_appearance $appearance auto, light or dark for the current page.
plugixa_video_design_presets $presets The design presets offered on the Appearance screen.
plugixa_video_site_styles $styles The complete site styles offered on the Appearance screen.
plugixa_video_binding_fields $fields, $card The video fields a block can bind to.
plugixa_video_library_tabs $tabs, $user_id Extra tabs in the member library: each an id, label and endpoint.
add_filter( 'plugixa_video_player_overlay', function ( string $overlay, int $video_id ) {
	return $overlay . '<span class="my-badge">New</span>';
}, 10, 2 );

Search engines

Filter Arguments What it changes
plugixa_video_schema $schema, $post A video’s VideoObject structured data. Return null to print none.

If your SEO plugin writes its own video structured data, switch the plugin’s off:

add_filter( 'plugixa_video_schema', '__return_null' );

Media

Part of Pro PRO.

Filter Arguments What it changes
plugixa_video_rungs $rungs The qualities that can be encoded: height => video kbps, label and work per second. 360, 480 and 720 with any licence.
plugixa_video_max_height $height The highest quality generated and served. 0 means no limit.
plugixa_video_quality_limit_note $note The text shown beside a quality above that limit.

To stop at 480p on a small server:

add_filter( 'plugixa_video_max_height', fn() => 480 );
Filter Arguments What it changes
plugixa_video_remote_details $details, $source, $remote_id What was found for a YouTube or Vimeo link: title, description, duration, thumbnail and author.

Analytics

Filter Arguments What it changes
plugixa_video_stats_address PRO $address The address used to tell viewers apart. It is hashed and never stored.
plugixa_video_stats_extras PRO $extras, $from, $to, $author Extra daily measures for the Analytics page, each with id, label, currency, total and days.
plugixa_video_count_view_on_source $count, $video_id Whether loading a video’s source counts as a view, for the simple view counter of the free plugin. Pro’s Analytics turns it off, because it counts real playback.

Settings and the API

Filter Arguments What it changes
plugixa_video_settings_defaults $defaults Default settings.
plugixa_video_filter_output $data, $entity_type Every successful REST answer, before it is sent.

Sales PRO

Filter Arguments What it changes
plugixa_video_receipt_email $mail, $payment, $order The receipt email: to, subject and message.
plugixa_video_renewal_failed_email $mail, $order, $event The failed-renewal email.
plugixa_video_invoice_prefix $prefix The invoice number prefix. Default INV-.
plugixa_video_webhook_url $url, $gateway The address given to Stripe or PayPal, for a site reached through a proxy or tunnel.

Internal hooks

These connect the plugin’s own parts and may change: plugixa_video_modules, plugixa_video_apps, plugixa_video_admin_config, plugixa_video_admin_i18n_strings, plugixa_video_bootstrap_payload, plugixa_video_settings_choices, plugixa_video_setup_pages, plugixa_video_filterable_fields, plugixa_video_search_fragments, plugixa_video_custom_values_table, plugixa_video_url_signer, plugixa_video_playable_url, plugixa_video_unlock_offers, plugixa_video_resolving_source, and in Pro plugixa_video_transcode_drivers, plugixa_video_playlist_uri, plugixa_video_master_media, plugixa_video_plan, plugixa_video_ai_providers, plugixa_video_ai_prices, plugixa_video_import_providers and plugixa_video_custom_fields_changed.

Hooks are not webhooks: they run inside WordPress. Stripe and PayPal send their notices to the REST routes described on the REST API page.

Quick Links

Share