Description
This filter can be used to modify the settings before a Dropbox shareable link is generated, allowing for the link to expire after a certain time or change who is allowed to access it.
Usage
The following would apply to all forms:
add_filter( 'gform_dropbox_shareable_link_settings', 'your_function_name', 10, 5 );
To target a specific form append the form id to the hook name. (format: gform_dropbox_shareable_link_settings_FORMID)
add_filter( 'gform_dropbox_shareable_link_settings_10', 'your_function_name', 10, 5 );
To target a specific field append both the form id and the field id to the hook name. (format: gform_dropbox_shareable_link_settings_FORMID_FIELDID)
add_filter( 'gform_dropbox_shareable_link_settings_10_3', 'your_function_name', 10, 5 );
Parameters
- $shareable_link_settings array
The shareable links settings. Possible values are public, team_only or password. More details can be found in Dropbox API docs.
array( 'requested_visibility' => 'public', );
-
$field_id string
The ID of the field currently being processed.
-
$form Form Object
The form currently being processed.
-
$entry Entry Object
The entry currently being processed.
-
$feed Feed Object
The feed currently being processed.
Examples
1. Team Only
This example allows the shareable link to only be accessible to members of the same Dropbox Business Plan team.
add_filter( 'gform_dropbox_shareable_link_settings', 'shareable_link_team_only', 10, 5 ); function shareable_link_team_only( $shareable_link_settings, $field_id, $form, $entry, $feed ) { $shareable_link_settings['requested_visibility'] = 'team_only'; return $shareable_link_settings; }
2. Password Protected
This example allows the shareable link to only be accessible with a specific password.
add_filter( 'gform_dropbox_shareable_link_settings', 'shareable_link_with_password', 10, 5 ); function shareable_link_with_password( $shareable_link_settings, $field_id, $form, $entry, $feed ) { $shareable_link_settings['requested_visibility'] = 'password'; $shareable_link_settings['link_password'] = 'Sup3rS3cr3tP@ssw0rd'; return $shareable_link_settings; }
3. Expiration Date
This example allows the shareable link to only be accessible for one week after creation.
add_filter( 'gform_dropbox_shareable_link_settings', 'shareable_link_one_week', 10, 5 ); function shareable_link_team_only( $shareable_link_settings, $field_id, $form, $entry, $feed ) { $shareable_link_one_week['expires'] = date( 'Y-m-d\TH:i:s\Z', strtotime( '+1 week' ) ); return $shareable_link_settings; }
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
gf_apply_filters( array( 'gform_dropbox_shareable_link_settings', $form['id'], $field_id ), array( 'requested_visibility' => 'public' ), $field_id, $form, $entry, $feed )
This filter is located in GFDropbox::upload_file() in class-gf-dropbox.php.