|
/ Docs /Presto Capture/ Presto Capture for Developers: REST API and PHP Filters

Presto Capture for Developers: REST API and PHP Filters

Building Presto Capture into a client site, or connecting it to another plugin? Presto Capture has action hooks that fire as recordings are saved, approved, and deleted, and a filter to change how the recorder looks. You can also tag a recorder with your own context, so every recording knows where it came from. This page lists what’s available and shows where to add your code.

Applies to: Presto Capture 1.0.0 and above.

Before You Begin

  • You should be comfortable with PHP and WordPress hooks.
  • Add your code to a child theme’s functions.php file or a code snippets plugin.
  • Don’t edit the plugin files, because updates will overwrite them.
  • Test every change on a staging site before you add it to your live site.

How to Add a Filter or Hook

  1. Open your child theme’s functions.php file, or add a new snippet in your code snippets plugin.
  2. Paste the code.
  3. Save the file or snippet.
  4. Record a test video on your staging site to check that the change works.

Here’s an example that changes the recorder’s accent colour on every recorder:

add_filter( 'presto_capture_branding', function ( $branding ) {	$branding['accentColor'] = '#1e40af';	return $branding;} );

Branding Filter

FilterWhat it changes
presto_capture_brandingThe accent colour, logo, brand name, font, header and button text. Receives $branding and $attributes. $attributes holds the block’s settings, so you can change branding for one recorder only.

Note: Presto Capture checks the branding values from Settings, but your filter runs after that check. Make sure the values you return are valid, for example a real hex colour.

Action Hooks

When a Recording Is Saved

do_action( 'presto_capture_recording_saved', int $post_id, array $meta );

This fires once a recording is saved as a Media Hub item (pp_video_block). It runs for both Bunny.net and Media Library saves, and also for recordings waiting for approval.

  • $post_id is the Media Hub item ID.
  • $meta holds the recording’s details:
Meta keyWhat it holds
_presto_capture_submitterThe user ID of the person who recorded it
_presto_capture_destinationbunny or self-hosted
_presto_capture_methodHow it was recorded: camera, screen, screen-camera or audio
_presto_capture_durationLength in seconds
_presto_capture_source_postThe ID of the page the recorder was on
_presto_capture_source_urlThe URL of the page the recorder was on
_presto_capture_source_typeYour integration’s source type (see Building Your Own Integration)
_presto_capture_source_idYour integration’s ID for the item the recorder was attached to
_presto_capture_source_sessionYour integration’s session value

Note: Use _presto_capture_submitter to find who recorded a video, not post_author. For some users, post_author is 0.

There is no block or shortcode ID in $meta. Read these values from the post instead:

  • Presto Player video row: get_post_meta( $post_id, '_presto_capture_video_row', true )
  • Media Library file: the attachment whose _presto_capture_recording_file meta equals $post_id
  • Status: get_post_status( $post_id ). A recording waiting for approval is pending.

When Bunny.net Finishes Processing

do_action( 'presto_capture_bunny_resolved', int $post_id );

For Bunny.net recordings, presto_capture_recording_saved fires while Bunny is still processing the video. This hook fires once Bunny reports the video as ready or failed.

Moderation and Deletion

HookWhen it fires
presto_capture_recording_approvedAn admin approves a pending recording. Receives $post_id.
presto_capture_recording_rejectedAn admin rejects or deletes a recording from the Recordings screen, just before it’s deleted. Receives $post_id. There is no “rejected but kept” status.
presto_capture_recording_deletedAny recording is deleted, including by auto-delete. Receives $post_id and $meta_before, the recording’s meta from before the delete.
presto_capture_orphan_deletedAuto-delete removes an unattached recording. Receives $post_id.

A pending recording plays only for admins and the person who recorded it.

Building Your Own Integration

You can connect Presto Capture to another plugin, so a recording is posted wherever the member recorded it. Here’s how the pieces fit together.

1. Add the Recorder With Your Context

Render the recorder from PHP and pass a source:

echo \PrestoCapture\Blocks\CaptureRenderer::render(	array( 'label' => 'Record a video' ),	null,	array(		'type'    => 'my-plugin',		'id'      => $item_id,		'session' => $session,	));
  • type, id and session are signed, so visitors can’t change them.
  • They come back in $meta as _presto_capture_source_type, _presto_capture_source_id and _presto_capture_source_session.
  • The [ presto_capture ] shortcode can’t carry a source. Use the PHP method instead.

2. Link the Recording

In your presto_capture_recording_saved callback, check the source type and link the recording to your item:

\PrestoCapture\Media\CaptureMeta::link( $post_id, 'my-plugin-' . $item_id );

Important: A recording with a source type counts as “unattached” until you call link(). Auto-delete removes unattached recordings after 30 days. You can change or turn off this period in Presto Capture’s General settings.

Before you publish the recording in your plugin, check get_post_status( $post_id ). If it’s pending, wait for presto_capture_recording_approved.

3. Show the Recording

Use the Presto Player shortcode with the Media Hub item ID:

echo do_shortcode( '[presto_player id=' . $post_id . ']' );

4. Control Who Can Play It

By default, a recording with a source type only plays for admins and the person who recorded it. To let others watch it, answer this filter for your source type:

add_filter( 'presto_capture_recording_visible', function ( $visible, $recording_id, $source_type ) {	if ( 'my-plugin' !== $source_type ) {		return $visible;	}	// Replace with your own access check.	return my_plugin_user_can_view( get_current_user_id(), $recording_id ) ? true : $visible;}, 10, 3 );
  • The filter runs only after the recording is linked.
  • Return true (a real boolean) to allow playback.
  • Admins and the person who recorded it can always play it.

Note: This filter controls the player only. If the video files themselves must be private, use a private Bunny.net library or private Media Library storage.

5. Clean Up

Hook presto_capture_recording_rejected and presto_capture_recording_deleted to remove the matching item in your plugin when a recording is rejected or deleted.

REST API

Presto Capture’s REST API is used by its own admin screens and the recorder. It isn’t meant for custom code, so use the PHP hooks above instead.

For example, to list one member’s recordings:

$recordings = new WP_Query( array(	'post_type'  => 'pp_video_block',	'meta_key'   => '_presto_capture_submitter',	'meta_value' => $user_id,) );

Good to Know

  • Settings changes apply to new blocks only. Filters run on every request, so they affect existing recorders too.
  • Recording limits and upload settings are managed from Presto Capture’s Settings. If your project needs something the settings don’t cover, contact our support team.
  • If you need a hook that isn’t listed here, tell us what you’re building.

You now have everything you need to connect Presto Capture to the rest of your site. Start small, test on staging, and build up from there.

If you have any questions or need further help, feel free to reach out to our support team. We’re always happy to help!

Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
Table of Contents