Hooks & Filters
Vimeify provides over 50 hooks and filters for customizing and extending functionality. This reference documents all available hooks.
Upload Hooks
Action: vimeify_before_upload
Fires before video upload begins.
Parameters:
$file_path(string) - Path to video file$args(array) - Upload arguments
Example:
add_action( 'vimeify_before_upload', function( $file_path, $args ) {
// Validate file
// Modify upload args
// Log upload attempt
error_log( "Uploading: {$file_path}" );
}, 10, 2 );Action: vimeify_after_upload
Fires after successful video upload.
Parameters:
$video_id(int) - WordPress post ID$vimeo_data(array) - Vimeo API response
Example:
add_action( 'vimeify_after_upload', function( $video_id, $vimeo_data ) {
// Send notification
// Update external system
// Track analytics
wp_mail( '[email protected]', 'New Video', 'Video uploaded: ' . get_the_title( $video_id ) );
}, 10, 2 );Action: vimeify_upload_failed
Fires when video upload fails.
Parameters:
$file_path(string) - Path to video file$error(WP_Error) - Error object
Example:
add_action( 'vimeify_upload_failed', function( $file_path, $error ) {
// Log error
// Send alert
// Clean up temporary files
error_log( "Upload failed: " . $error->get_error_message() );
}, 10, 2 );Filter: vimeify_upload_args
Modify upload arguments before processing.
Parameters:
$args(array) - Upload arguments$file_path(string) - Path to video file
Returns: Modified $args array
Example:
add_filter( 'vimeify_upload_args', function( $args, $file_path ) {
// Force privacy for specific user roles
if ( ! current_user_can( 'publish_posts' ) ) {
$args['privacy'] = 'private';
}
// Add custom metadata
$args['description'] .= "\n\nUploaded via WordPress";
return $args;
}, 10, 2 );Filter: vimeify_upload_chunk_size
Modify upload chunk size for chunked uploads.
Parameters:
$size(int) - Chunk size in bytes
Returns: Modified chunk size
Example:
add_filter( 'vimeify_upload_chunk_size', function( $size ) {
// Increase chunk size for faster uploads
return 10 * 1024 * 1024; // 10MB
} );Filter: vimeify_allowed_upload_mimetypes
Modify allowed video MIME types.
Parameters:
$mimes(array) - Allowed MIME types
Returns: Modified MIME types array
Example:
add_filter( 'vimeify_allowed_upload_mimetypes', function( $mimes ) {
// Add additional video format
$mimes[] = 'video/x-matroska'; // .mkv
return $mimes;
} );Sync Hooks
Action: vimeify_before_sync
Fires before sync operation starts.
Parameters:
$sync_type(string) - Type of sync (metadata, status)
Example:
add_action( 'vimeify_before_sync', function( $sync_type ) {
// Log sync start
// Clear transients
// Prepare data
error_log( "Starting {$sync_type} sync" );
} );Action: vimeify_after_sync
Fires after sync operation completes.
Parameters:
$sync_type(string) - Type of sync$result(array) - Sync results
Example:
add_action( 'vimeify_after_sync', function( $sync_type, $result ) {
// Send report
// Update dashboard widget
// Clear cache
if ( $result['videos_synced'] > 0 ) {
wp_mail( '[email protected]', 'Sync Complete', "{$result['videos_synced']} videos synced" );
}
}, 10, 2 );Action: vimeify_sync_video
Fires after individual video is synced.
Parameters:
$post_id(int) - WordPress post ID$vimeo_data(array) - Vimeo video data
Example:
add_action( 'vimeify_sync_video', function( $post_id, $vimeo_data ) {
// Update custom fields
// Trigger webhooks
// Update search index
update_post_meta( $post_id, '_last_synced', time() );
}, 10, 2 );Action: vimeify_video_deleted
Fires when video is deleted during status sync.
Parameters:
$post_id(int) - WordPress post ID$vimeo_id(string) - Vimeo video ID
Example:
add_action( 'vimeify_video_deleted', function( $post_id, $vimeo_id ) {
// Clean up related data
// Log deletion
// Send notification
error_log( "Video {$vimeo_id} was deleted from Vimeo" );
}, 10, 2 );Filter: vimeify_sync_per_page
Modify number of videos processed per sync page.
Parameters:
$per_page(int) - Videos per page (default: 100)
Returns: Modified per_page value
Example:
add_filter( 'vimeify_sync_per_page', function( $per_page ) {
// Reduce to conserve API quota
return 50;
} );Filter: vimeify_sync_video_data
Modify video data before saving during sync.
Parameters:
$post_data(array) - WordPress post data$vimeo_data(array) - Vimeo video data
Returns: Modified post data
Example:
add_filter( 'vimeify_sync_video_data', function( $post_data, $vimeo_data ) {
// Customize post status
if ( $vimeo_data['privacy']['view'] === 'private' ) {
$post_data['post_status'] = 'draft';
}
// Modify content
$post_data['post_content'] .= "\n\n[Watch on Vimeo](" . $vimeo_data['link'] . ")";
return $post_data;
}, 10, 2 );Video Hooks
Action: vimeify_video_created
Fires when new video post is created.
Parameters:
$post_id(int) - WordPress post ID$vimeo_data(array) - Vimeo video data
Example:
add_action( 'vimeify_video_created', function( $post_id, $vimeo_data ) {
// Send welcome email
// Add to newsletter
// Create transcript post
}, 10, 2 );Action: vimeify_video_updated
Fires when video post is updated.
Parameters:
$post_id(int) - WordPress post ID$update_data(array) - Updated data
Example:
add_action( 'vimeify_video_updated', function( $post_id, $update_data ) {
// Clear page cache
// Regenerate thumbnails
// Update search index
}, 10, 2 );Filter: vimeify_video_post_type_args
Modify video post type registration arguments.
Parameters:
$args(array) - Post type arguments
Returns: Modified arguments
Example:
add_filter( 'vimeify_video_post_type_args', function( $args ) {
// Make videos hierarchical
$args['hierarchical'] = true;
// Change menu icon
$args['menu_icon'] = 'dashicons-video-alt2';
// Add support for comments
$args['supports'][] = 'comments';
return $args;
} );Filter: vimeify_video_meta
Modify video metadata before saving.
Parameters:
$meta(array) - Video metadata$post_id(int) - WordPress post ID
Returns: Modified metadata
Example:
add_filter( 'vimeify_video_meta', function( $meta, $post_id ) {
// Add custom tracking
$meta['_view_count'] = 0;
$meta['_featured_date'] = current_time( 'mysql' );
return $meta;
}, 10, 2 );Filter: vimeify_video_embed_html
Modify video embed HTML output.
Parameters:
$html(string) - Embed HTML$post_id(int) - WordPress post ID$args(array) - Embed arguments
Returns: Modified HTML
Example:
add_filter( 'vimeify_video_embed_html', function( $html, $post_id, $args ) {
// Add wrapper div
return '<div class="video-wrapper" data-video-id="' . $post_id . '">' . $html . '</div>';
}, 10, 3 );Filter: vimeify_video_thumbnail_url
Modify video thumbnail URL.
Parameters:
$url(string) - Thumbnail URL$post_id(int) - WordPress post ID$size(string) - Thumbnail size
Returns: Modified URL
Example:
add_filter( 'vimeify_video_thumbnail_url', function( $url, $post_id, $size ) {
// Use custom CDN
return str_replace( 'i.vimeocdn.com', 'cdn.mysite.com', $url );
}, 10, 3 );Gallery Hooks
Action: vimeify_gallery_created
Fires when gallery is created.
Parameters:
$gallery_id(int) - Gallery post ID$gallery_type(string) - Gallery type (selection, folder_sync)
Example:
add_action( 'vimeify_gallery_created', function( $gallery_id, $gallery_type ) {
// Initialize custom settings
// Send notification
// Log creation
}, 10, 2 );Action: vimeify_gallery_synced
Fires after folder sync gallery is synchronized.
Parameters:
$gallery_id(int) - Gallery post ID$video_ids(array) - Array of synced video IDs
Example:
add_action( 'vimeify_gallery_synced', function( $gallery_id, $video_ids ) {
// Update gallery cache
// Send update notification
// Regenerate sitemap
}, 10, 2 );Filter: vimeify_gallery_query
Modify gallery video query arguments.
Parameters:
$args(array) - WP_Query arguments$gallery_id(int) - Gallery post ID
Returns: Modified query args
Example:
add_filter( 'vimeify_gallery_query', function( $args, $gallery_id ) {
// Only show published videos
$args['post_status'] = 'publish';
// Limit to 20 videos
$args['posts_per_page'] = 20;
// Order by title
$args['orderby'] = 'title';
$args['order'] = 'ASC';
return $args;
}, 10, 2 );Filter: vimeify_gallery_videos
Modify gallery videos array after query.
Parameters:
$videos(array) - Array of WP_Post objects$gallery_id(int) - Gallery post ID
Returns: Modified videos array
Example:
add_filter( 'vimeify_gallery_videos', function( $videos, $gallery_id ) {
// Filter by custom meta
return array_filter( $videos, function( $video ) {
return get_post_meta( $video->ID, '_featured', true ) === 'yes';
} );
}, 10, 2 );Filter: vimeify_gallery_html
Modify gallery HTML output.
Parameters:
$html(string) - Gallery HTML$gallery_id(int) - Gallery post ID$args(array) - Display arguments
Returns: Modified HTML
Example:
add_filter( 'vimeify_gallery_html', function( $html, $gallery_id, $args ) {
// Add gallery header
$title = get_the_title( $gallery_id );
return '<div class="gallery-header"><h2>' . $title . '</h2></div>' . $html;
}, 10, 3 );Filter: vimeify_gallery_style_classes
Add custom CSS classes to gallery container.
Parameters:
$classes(array) - CSS classes$gallery_id(int) - Gallery post ID$style(string) - Gallery style (slider, playlist)
Returns: Modified classes array
Example:
add_filter( 'vimeify_gallery_style_classes', function( $classes, $gallery_id, $style ) {
// Add custom class
$classes[] = 'custom-gallery';
// Add style-specific class
if ( $style === 'slider' ) {
$classes[] = 'fancy-slider';
}
return $classes;
}, 10, 3 );Settings Hooks
Filter: vimeify_default_settings
Modify default plugin settings.
Parameters:
$defaults(array) - Default settings
Returns: Modified defaults
Example:
add_filter( 'vimeify_default_settings', function( $defaults ) {
// Change default privacy
$defaults['default_privacy'] = 'unlisted';
// Enable auto-publish
$defaults['auto_publish'] = true;
return $defaults;
} );Filter: vimeify_api_credentials
Modify API credentials (use with caution).
Parameters:
$credentials(array) - API credentials
Returns: Modified credentials
Example:
add_filter( 'vimeify_api_credentials', function( $credentials ) {
// Use different credentials for specific users
if ( current_user_can( 'administrator' ) ) {
$credentials['access_token'] = 'admin_token';
}
return $credentials;
} );Action: vimeify_settings_saved
Fires after settings are saved.
Parameters:
$settings(array) - Saved settings
Example:
add_action( 'vimeify_settings_saved', function( $settings ) {
// Clear cache
// Trigger resync if needed
// Log settings change
if ( $settings['sync_behavior'] === 'create_all' ) {
// Trigger full sync
do_action( 'vimeify_trigger_full_sync' );
}
} );Upload Profile Hooks
Filter: vimeify_upload_profile_settings
Modify upload profile settings.
Parameters:
$settings(array) - Profile settings$profile_id(int) - Profile post ID
Returns: Modified settings
Example:
add_filter( 'vimeify_upload_profile_settings', function( $settings, $profile_id ) {
// Override privacy for specific profiles
if ( get_post_meta( $profile_id, '_client_profile', true ) ) {
$settings['privacy'] = 'private';
}
return $settings;
}, 10, 2 );Filter: vimeify_default_upload_profile
Change default upload profile.
Parameters:
$profile_id(int) - Default profile ID
Returns: Modified profile ID
Example:
add_filter( 'vimeify_default_upload_profile', function( $profile_id ) {
// Use different profile for specific user roles
if ( current_user_can( 'contributor' ) ) {
return 456; // Contributor profile ID
}
return $profile_id;
} );Admin Hooks
Action: vimeify_admin_menu
Fires when admin menu is registered.
Example:
add_action( 'vimeify_admin_menu', function() {
// Add custom admin page
add_submenu_page(
'vimeify',
'Custom Page',
'Custom',
'manage_options',
'vimeify-custom',
'my_custom_page_callback'
);
} );Filter: vimeify_admin_columns
Modify video list table columns.
Parameters:
$columns(array) - Column definitions
Returns: Modified columns
Example:
add_filter( 'vimeify_admin_columns', function( $columns ) {
// Add custom column
$columns['views'] = 'Views';
// Remove column
unset( $columns['date'] );
return $columns;
} );Action: vimeify_admin_column_content
Output custom column content.
Parameters:
$column(string) - Column name$post_id(int) - Post ID
Example:
add_action( 'vimeify_admin_column_content', function( $column, $post_id ) {
if ( $column === 'views' ) {
$views = get_post_meta( $post_id, '_view_count', true );
echo number_format( $views );
}
}, 10, 2 );Shortcode Hooks
Filter: vimeify_shortcode_atts
Modify shortcode attributes.
Parameters:
$atts(array) - Shortcode attributes$shortcode(string) - Shortcode name
Returns: Modified attributes
Example:
add_filter( 'vimeify_shortcode_atts', function( $atts, $shortcode ) {
if ( $shortcode === 'vimeify_video' ) {
// Force autoplay off
$atts['autoplay'] = false;
}
return $atts;
}, 10, 2 );Filter: vimeify_shortcode_output
Modify shortcode HTML output.
Parameters:
$output(string) - Shortcode HTML$atts(array) - Shortcode attributes$shortcode(string) - Shortcode name
Returns: Modified HTML
Example:
add_filter( 'vimeify_shortcode_output', function( $output, $atts, $shortcode ) {
// Add wrapper
return '<div class="vimeify-shortcode-wrapper">' . $output . '</div>';
}, 10, 3 );REST API Hooks
Filter: vimeify_rest_video_response
Modify REST API video response.
Parameters:
$response(array) - Video data$post_id(int) - Post ID
Returns: Modified response
Example:
add_filter( 'vimeify_rest_video_response', function( $response, $post_id ) {
// Add custom fields
$response['custom_field'] = get_post_meta( $post_id, '_custom', true );
// Add computed values
$response['url_slug'] = sanitize_title( $response['title'] );
return $response;
}, 10, 2 );Filter: vimeify_rest_authentication
Add custom REST API authentication.
Parameters:
$user(WP_User|false) - Authenticated user or false
Returns: WP_User object or false
Example:
add_filter( 'vimeify_rest_authentication', function( $user ) {
// Custom API key authentication
if ( isset( $_SERVER['HTTP_X_API_KEY'] ) ) {
$api_key = $_SERVER['HTTP_X_API_KEY'];
$user_id = get_user_by_api_key( $api_key );
if ( $user_id ) {
return get_user_by( 'ID', $user_id );
}
}
return $user;
} );Performance Hooks
Filter: vimeify_cache_duration
Modify cache duration for various operations.
Parameters:
$duration(int) - Cache duration in seconds$cache_key(string) - Cache identifier
Returns: Modified duration
Example:
add_filter( 'vimeify_cache_duration', function( $duration, $cache_key ) {
// Longer cache for folders
if ( $cache_key === 'vimeo_folders' ) {
return HOUR_IN_SECONDS;
}
return $duration;
}, 10, 2 );Filter: vimeify_lazy_load_videos
Enable/disable lazy loading for videos.
Parameters:
$enabled(bool) - Whether lazy loading is enabled
Returns: Modified boolean
Example:
add_filter( 'vimeify_lazy_load_videos', function( $enabled ) {
// Enable on frontend only
return ! is_admin();
} );Validation Hooks
Filter: vimeify_validate_upload
Custom upload validation.
Parameters:
$valid(bool|WP_Error) - Validation result$file_path(string) - File path$args(array) - Upload arguments
Returns: true or WP_Error
Example:
add_filter( 'vimeify_validate_upload', function( $valid, $file_path, $args ) {
// Check file size
$max_size = 500 * 1024 * 1024; // 500MB
if ( filesize( $file_path ) > $max_size ) {
return new WP_Error( 'file_too_large', 'File must be under 500MB' );
}
// Check video dimensions
// Validate metadata
// Custom business logic
return $valid;
}, 10, 3 );Filter: vimeify_can_upload
Check if user can upload videos.
Parameters:
$can_upload(bool) - Whether user can upload$user_id(int) - User ID
Returns: Modified boolean
Example:
add_filter( 'vimeify_can_upload', function( $can_upload, $user_id ) {
// Check subscription status
if ( ! user_has_active_subscription( $user_id ) ) {
return false;
}
// Check upload quota
$uploads_this_month = get_user_upload_count( $user_id );
if ( $uploads_this_month >= 10 ) {
return false;
}
return $can_upload;
}, 10, 2 );Hook Priority Best Practices
Default Priority (10)
Most hooks use priority 10 by default:
add_action( 'vimeify_after_upload', 'my_function' ); // Priority 10Early Execution (5 or lower)
Run before default hooks:
add_filter( 'vimeify_upload_args', 'validate_early', 5 );Late Execution (15 or higher)
Run after default hooks:
add_action( 'vimeify_after_sync', 'cleanup_late', 15 );Critical Order
When order matters:
// Must run first
add_action( 'vimeify_before_upload', 'critical_check', 1 );
// Must run last
add_action( 'vimeify_after_upload', 'final_cleanup', 999 );Related
- API Reference - PHP and REST APIs
- CLI Commands - WP-CLI hooks
- Frontend Uploads - Form integration
- Examples - Hook examples