WP Cloud Plugins
PluginsPlayground ↗⏵ Open Ticket
  • Getting Started
    • System Requirements
    • Installation
    • Connect a Cloud Account
    • Add your First Module
    • How to Update?
  • Licensing
    • Activate License
    • Deactivate/Move license
    • Local/Staging sites
    • License FAQ
  • Global Options
    • Layout
    • Personal Folders
    • Review & Approve
    • Integrations
    • Notifications
    • Permissions
    • Usage Limits
    • Security
    • Advanced
    • Statistics
    • Tools
  • Modules
    • Module Manager
    • Module Configurator
      • Content
      • Accessibility
      • Dynamic Folders
      • Actions
      • Review & Approve
      • Layout
      • Sort Order
      • Filters
      • Upload Settings
      • Usage Limits
      • Notifications
    • Modules
      • Audio player
      • Button
      • Embed
      • File Browser
      • Gallery
      • List
      • Review & Approve
      • Search Box
      • Slider / Carousel
      • Upload Box
      • Video player
  • Features
    • Dynamic Folders
      • Automatic mode
      • Manual mode
    • Personal Folders
      • FAQs
    • Embed documents
    • Import to Media Library
    • Video Advertisements
    • Statistics
    • Webhooks
  • Integrations
    • Advanced Custom Fields (ACF)
    • Form Plugins
      • Contact Form 7
      • Fluent Forms
      • Formidable Forms
      • Gravity Forms
      • GravityPDF
      • NinjaForms
      • WPForms
    • Page Builders
      • Beaver Builder
      • Classic Editor
      • Divi Page Builder
      • Gutenberg
      • Elementor
    • Slack
    • Uncanny Automator
    • WooCommerce
      • Digital Downloads
      • Order Uploads
    • Easy Digital Downloads (EDD)
  • Developers
    • Actions
    • API
      • copy()
      • copy_folder_recursive()
      • create_folder()
      • create_edit_url()
      • create_preview_url()
      • create_shared_url()
      • create_temporarily_download_url()
      • delete()
      • download()
      • get_entry()
      • get_folder()
      • move()
      • patch()
      • rename()
      • set_account_by_id()
      • set_drive_by_id()
      • upload_file()
    • Filters
    • Placeholders
  • Other
    • FAQs
    • Translations
    • Vulnerabilities
    • Support
      • Scope
      • Open a Support Ticket
    • About Us
    • Changelog
Powered by GitBook
On this page
  • Available events types
  • Example Data
  • Example listener (PHP)
  1. Features

Webhooks

The built-in Webhooks feature provides an easy way to automate notifications based on events logged by the plugin. When enabled, the plugin sends a detailed JSON object to a specified listener URL, containing all relevant information about the logged event.

You can activate Webhook functionality via the Statistics tab under Log Events → Webhook Endpoint URL. This allows you to stay updated on plugin activities and seamlessly integrate with other systems.

Available events types

useyourdrive_previewed_entry useyourdrive_edited_entry useyourdrive_downloaded_entry useyourdrive_streamed_entry useyourdrive_created_link_to_entry useyourdrive_renamed_entry useyourdrive_deleted_entry useyourdrive_created_entry useyourdrive_updated_description useyourdrive_updated_metadata useyourdrive_moved_entry useyourdrive_uploaded_entry useyourdrive_uploaded_failed useyourdrive_searched useyourdrive_sent_notification useyourdrive_error

Example Data

{
  "total": 1,
  "events": [
    {
      "timestamp": "2022-05-01T00:05:00+00:00",
      "type": "useyourdrive_previewed_entry",
      "description": "John Johnson previewed the file UK Festival Market Report.pdf",
      "data": {
        "entry": {
          "id": "1-y9psKPDJCycz38c2sN_a3lRoO9S",
          "name": "UK Festival Market Report.pdf",
          "mimetype": "application/pdf",
          "size": "2 MB",
          "icon": "https://...",
          "description": "Festival Insights and the UK Festival Awards are proud to release the UK Festival Market Report 2017.",
          "thumbnail": "https://...",
          "preview_url": "https://...",
          "download_url": "https://...",
          "is_dir": false,
          "parent_id": "0By3zfuC9ZTdGZCT1pUd0E",
          "parent_path": "/Path/To/Folder"
        },
        "account": {
          "id": "1030123322434145",
          "name": "Your Account name",
          "email": "info@example.com",
          "image": "https://..."
        }
      },
      "user": {
        "id": "3",
        "user_login": "John Johnson",
        "user_nicename": "john-johnson",
        "user_email": "info@example.com",
        "display_name": "John Johnson"
      },
      "page": "https://yoursite.com/page"
    },
    {
        "timestamp": "2022-05-01T00:05:01+00:00",
        "type": "useyourdrive_deleted_entry",
        ...
    }
  ]
}

Example listener (PHP)

// Optional: Prevent replay attacks by ensuring this request has been signed
// recently (+/- 5 minutes). The request timestamp is in ms!
$time_difference = abs((time() - intval($_SERVER['HTTP_X_WPCP_TIMESTAMP'])) / 1000);

if ($time_difference > 300) {
  exit('Invalid request timestamp');
}

// Calculate challenge hash by concatenating the request timestamp with the
// webhook secret with a semicolon in between: "timestamp;secret".
// Hash is created with SHA256 encoded as hexdecimal lowercase string.
$secret = 'your_secret';
$challenge = hash('sha256', $req_timestamp.';'.$secret);

// Calculate request body signature using the challenge hash as secret.
// Signature is a HMAC SHA256 hash encoded as hexdecimal lowercase string.
$req_raw_body = file_get_contents('php://input');
$expected_signature = 'sha256='.hash_hmac('sha256', $req_raw_body, $challenge);

// Compare expected with received signature.
$req_signature = $_SERVER['HTTP_X_WPCP_SIGNATURE'];

if ($expected_signature !== $req_signature) {
  exit('Invalid signature');
}

// Finally, parse the JSON request body and process the received events.
$data = json_decode($req_raw_body, true);

PreviousStatisticsNextAdvanced Custom Fields (ACF)

Last updated 5 months ago