DocsOFeedbackDeveloper API & Hooks
Developer

Developer API & Hooks

OFeedbackorravo.com/docs/ofeedback/developer-api

PHP Functions

php// Query submissions with filtering and pagination
$submissions = OFB_DB::query([
    'status'    => 'new',            // '', 'new', 'read', 'archived'
    'type'      => 'bug',
    'search'    => 'login page',
    'date_from' => '2025-01-01',     // Y-m-d
    'date_to'   => '2025-12-31',
    'orderby'   => 'created_at',
    'order'     => 'DESC',
    'per_page'  => 20,
    'paged'     => 1,
]);

// Get single submission
$entry = OFB_DB::get( 42 );

// Count by status
$total  = OFB_DB::count_by_status();
$unread = OFB_DB::count_by_status('new');

// Analytics
OFB_DB::analytics_by_type(): array    // [ 'bug' => 12, 'general' => 8, … ]
OFB_DB::analytics_by_rating(): array  // [ 1 => 2, 2 => 5, 3 => 10, 4 => 18, 5 => 6 ]
OFB_DB::analytics_by_date( 30 ): array  // [ 'Y-m-d' => count, … ]
OFB_DB::average_rating(): float

// Types
OFB_Submission::types(): array          // all types [ 'general' => 'General Feedback', … ]
OFB_Submission::enabled_types(): array  // only currently enabled types

Action Hooks

php// Fires after a new submission is saved (after email + Slack notifications)
add_action( 'ofeedback_submission_created', function( int $id, array $data ) {
    // $data contains: type, message, name, email, rating, page_url, etc.
    error_log( 'New feedback #' . $id );
}, 10, 2 );

Filter Hooks

php// Filter notification recipients
add_filter( 'ofb_notify_email', function( string $email ): string {
    return 'feedback@example.com, team@example.com';
} );

Screenshot Capture

html2canvas (loaded from jsDelivr CDN on demand only when user clicks "Attach Screenshot") captures the visible page, compresses to JPEG (quality 0.72, max 1280px), uploads via AJAX ofb_upload_screenshot. The server validates magic bytes (JPEG/PNG only), enforces 2 MB limit, saves to wp-content/uploads/ofb-screenshots/. The directory is protected by .htaccess blocking PHP execution and directory listing.

Developer API & Hooks — OFeedback Docs — Orravo