Skip to content

Hooks and Filters Reference

MediaShield overviewFree + ProGet MediaShield →

PRO - requires MediaShield Pro. This page lists the hooks Pro fires (6 actions, 12 filters), the queued job hooks it registers, and the Free hooks it listens to. Each name was checked against the 1.4.0 source.

Free 1.4.1 adds two filters that integrations answer: mediashield_guest_can_watch (let a guest past Require Login, for example on a free-preview lesson) and mediashield_video_watch_url (the page the My Videos block links to). Pro does not use either. They are documented in the Free Hooks and Filters reference.

Most Pro hooks use the mediashield_pro_* prefix. A few older ones keep the plain mediashield_* or ms_* prefix and are fired as they are.

Action Arguments Fired when
mediashield_pro_loaded none Pro finished booting (plugins_loaded priority 20)
mediashield_pro_privacy_before_erase string $email, WP_User|false $user, int $page, object $counters Before Pro’s GDPR eraser runs. Add to $counters->items_removed or items_retained
mediashield_lms_lesson_completed int $user_id, int $video_id, int $lesson_id, string $lms_slug After a lesson was auto-completed from a milestone
mediashield_lms_adapters_loaded array $adapters After the LMS adapters are registered. Read only. Use the filter to add one
mediashield_bunny_encoded int $post_id, string $video_guid, array $body Bunny reported a video finished encoding
mediashield_bunny_failed int $post_id, string $video_guid, array $body Bunny reported an encoding error
add_action( 'mediashield_lms_lesson_completed', function ( $user_id, $video_id, $lesson_id, $lms ) {
// For example, send the student to a CRM.
}, 10, 4 );
Filter Arguments Purpose
mediashield_lms_adapters array $adapters (slug => adapter object) Register an LMS adapter. Entries must implement MediaShieldPro\LMS\LMSAdapterInterface. Anything else is skipped with a _doing_it_wrong notice. Runs on plugins_loaded priority 30
mediashield_pro_render_linked_lesson_video bool $render, int $video_id, int $post_id Return false to stop Pro adding the linked video to a lesson’s content
mediashield_pro_license_valid bool $valid Override the licence check result
mediashield_pro_privacy_export_result array $result, string $email, WP_User|false $user, int $page Final GDPR export payload
mediashield_pro_privacy_erase_result array $result, string $email, WP_User|false $user, int $page Final GDPR erase receipt
mediashield_pro_playback_event_retention_days int $days (default 90, minimum 2) How long raw playback events are kept
mediashield_vpn_lookup_url string $template The VPN lookup URL template. %1$s is the encoded IP, %2$s the key. Pointing it at your own resolver removes the need for an ip-api key
mediashield_pro_bunny_stream_url string $url, string $platform_video_id, int $video_id The derived Bunny playback URL
mediashield_pro_bunny_direct_play bool $enabled (from ms_bunny_direct_play) Force direct playback on or off
mediashield_pro_bunny_prefer_mp4 bool $prefer (from ms_bunny_prefer_mp4) Use the MP4 rendition instead of HLS
mediashield_pro_bunny_token_ttl int $seconds (default 6 hours) Lifetime of signed Bunny addresses
mediashield_pro_bunny_token_key string $key The Bunny token authentication key used for signing
// Keep raw playback events for 30 days.
add_filter( 'mediashield_pro_playback_event_retention_days', fn() => 30 );
// Do not add the video to lessons automatically.
add_filter( 'mediashield_pro_render_linked_lesson_video', '__return_false' );

Pro also applies the Free filter mediashield_enqueue_frontend before it registers its own front-end script.

These are queued jobs, not extension points. They run through Action Scheduler in the mediashield-pro group.

Hook Schedule Arguments What it does
ms_heatmap_aggregation Hourly none Builds the heatmap cache
ms_playback_event_retention Daily none Deletes playback events past the retention window
ms_alert_pruning Daily none Deletes dismissed alerts older than 90 days
ms_weekly_digest Weekly, Monday 08:00 site time none Sends the digest email
ms_vpn_lookup On demand string $ip, int $user_id, int $video_id One VPN lookup per new viewer address
mediashield_generate_pdf On demand int $user_id, array $filters, string $report_id Builds a PDF report
mediashield_fire_webhook On demand string $url, array $payload Delivers a milestone webhook. Runs inline when Action Scheduler is missing
Free hook Pro class Priority Purpose
mediashield_can_watch (filter) Access\RoleAccess 20 Role check (same rule as Free)
mediashield_can_watch (filter) The three LMS adapters 25 Enrollment gate. Only attached when the site-wide enrollment switch is on
mediashield_settings_response (filter) ProSettings, AdvancedConfig 10 Add Pro settings to GET /settings
mediashield_settings_update (filter) ProSettings, AdvancedConfig 10 Save Pro settings from PUT /settings and remove them from the data Free sees
mediashield_upload_drivers (filter) Core\Plugin 10 Register the Bunny, Vimeo, YouTube and Wistia drivers
mediashield_default_upload_driver (filter) Core\Plugin 10 Answer “auto” with the first active connection
mediashield_watermark_config (filter) Watermark\AdvancedConfig 10 Build the watermark text from the chosen fields
mediashield_video_stream_url (filter) Platform\BunnyUrls 10 Derive the Bunny playback URL
mediashield_bunny_pull_zones (filter) Platform\BunnyUrls 10 Tell Free which pull zones are yours
mediashield_video_ads (filter) Ads\AdResolver 10 Choose creatives for a video
mediashield_ad_break_plan (filter) Ads\AdResolver 10 Apply a video’s own break placement
mediashield_milestone_reached (action) Milestones\AdvancedActions, the LMS adapters 10 Run milestone actions and complete lessons
mediashield_session_started (action) SuspiciousActivity (10), VpnDetection (20) 10, 20 Multiple IP check and VPN lookup
mediashield_devtools_detected (action) SuspiciousActivity 10 Record a Developer tools alert
mediashield_upload_started, _complete, _failed (actions) Upload\UploadQueue 10 Keep the upload queue

Also used from WordPress core:

Hook Class Purpose
the_content (filter, priority 20) LMS\LMSManager Add the linked video to a lesson
rest_request_after_callbacks (filter) Analytics\PlaybackRecorder Record a playback event from each free session heartbeat
wp_privacy_personal_data_exporters / _erasers (filters) ProPrivacyExporter, ProPrivacyEraser Pro’s GDPR groups

Pro does not listen to Free’s mediashield_privacy_before_erase.