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
  1. Developers
  2. API

create_shared_url()

Create a preview url

create_preview_url()

Create a shared url for a file or folder and update its sharing permissions.

OneDrive Premium and Business accounts can request an expiring shared link or set a password.

Parameters

Name
Type
Description

$id

string

ID of the entry

$param

array

Additional sharing permissions. Defaults to:

Return

Name
Type
Description

$url

string

The created shared link

Usage

WPCP_ONEDRIVE_API::set_account_by_id('8c9bacda0-d8d8-4b22-b634-7b5281687575');
WPCP_ONEDRIVE_API::set_drive_by_id('b!DlaHWskCed_MIid3KpJH5Lbatf9HsdXBAZH5YcvPAbMhJUKzTJyzgvXZYpBS');

$params = [
    'type' => 'view',
    'scope' => 'anonymous',
];

// Set password
// !!! Only available for OneDrive Business
$params['password'] = 'mypass1234';

// Set expire date
// !!! Only available for OneDrive Business
$expire_date = current_datetime()->modify('+1 month');
$params['unshared_at'] = $expire_date->setTimezone(new \DateTimeZone('UTC'))->format('Y-m-d\TH:i:s\Z');

// Create / Get shared links
$url = WPCP_ONEDRIVE_API::create_shared_url('01EXLSWHWMQZNDMLRG7NFIWAVYCFJAXP2R', $params);

Parameters

Name
Type
Description

$id

string

ID of the entry

$params

array

Additional params for sharing permissions. Default:

Return

Name
Type
Description

$url

string

The created shared link

Usage

WPCP_GDRIVE_API::set_account_by_id('201096615285735764133')

$params = [
  'role' => 'reader'
];

// Create / Get shared links
$url = WPCP_GDRIVE_API::create_shared_url('1wzWlDMsZkA4N5yEEAmMigp52u7M0Lk_7', $params);

Dropbox Pro, Business and Enterprise accounts can request e.g. read_only or password protected links.

Parameters

Name
Type
Description

$id

string

ID of the entry

$param

array

Additional sharing permissions. Defaults to:

Return

Name
Type
Description

$url

string

The created shared link

Usage

WPCP_DROPBOX_API::set_account_by_id('dbid:AADSy6JxzbgqCs4A43CAAAfO9xvZwpcsLU');

// Set password for link
// !!! Only available for Pro, Business
$params = [
    'require_password' => true,
    'link_password' => 'mypass1234',
];

// Set expire date
// !!! Only available for Pro, Business
$expire_date = current_datetime()->modify('+1 month');
$params['expires'] = $expire_date->setTimezone(new \DateTimeZone('UTC'))->format('Y-m-d\TH:i:s\Z');

// Create / Get shared links
$shared_links = WPCP_DROPBOX_API::create_shared_url('id:4tUAwPCAdf0b0AAAAA_iw', $params);

Box Pro, Business and Enterprise accounts can request an expiring shared link.

Parameters

Name
Type
Description

$id

string

ID of the entry

$is_dir

bool

Is the entry a folder or a file?

$param

array

Additional sharing permissions. Defaults to:

Return

Name
Type
Description

$url

string

The created shared link

Usage

WPCP_BOX_API::set_account_by_id('29232154182');

// Set password for link
$params = [
    'access' => 'open',
    'password' => 'mypass1234',
];

// Set readonly link
$params['permissions']['can_download'] = false;

// Set expire date
// !!! Only available for Pro, Business
$expire_date = current_datetime()->modify('+1 month');
$params['unshared_at'] = $expire_date->format(DATE_RFC3339);

// Create / Get shared links
$shared_links = WPCP_BOX_API::create_shared_url('51142665', $params);

Previouscreate_preview_url()Nextcreate_temporarily_download_url()

Last updated 6 months ago

$param = [
  'type' => 'view',
  'scope' => 'anonymous',
];
$param = [
    'role' => 'reader',
];
$param = [
    'audience' => 'public',
    'access' => 'viewer',
    'expires' => null,
    'require_password' => null,
    'link_password' => null,
];
$param = [
  'access' => 'open',
  'password' => null,
  'permissions' => [
      'can_download' => true,
  ],
  'unshared_at' => null,
];