gform_dropbox_store_local_version

gform_dropbox_store_local_version

DescriptionUsageParametersExamples1. Simple Usage2. Advanced UsagePlacementSource Code

Description
This filter can be used to keep a local copy of the file being retained once it has been uploaded to Dropbox.
Usage
The following would apply to all forms:
add_filter( 'gform_dropbox_store_local_version', 'your_function_name', 10, 6 );

To target a specific form append the form id to the hook name. (format: gform_dropbox_store_local_version_FORMID)
add_filter( 'gform_dropbox_store_local_version_10', 'your_function_name', 10, 6 );

To target a specific field append both the form id and the field id to the hook name. (format: gform_dropbox_store_local_version_FORMID_FIELDID)
add_filter( 'gform_dropbox_store_local_version_10_3', 'your_function_name', 10, 6 );

Parameters

$store_local_version boolean
Should a local copy of the file be retained? Default is false.

$file array
The file properties.
array(
'name' => basename( $entry[ rgar( $field, 'id' ) ] ),
'path' => str_replace( WP_CONTENT_URL, WP_CONTENT_DIR, $entry[ rgar( $field, 'id' ) ] ),
'url' => $entry[ $field['id'] ],
'destination' => rgars( $feed, 'meta/destinationFolder' ),
);

$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. Simple Usage
This example shows the simplest way to use the hook.
add_filter( 'gform_dropbox_store_local_version', '__return_true' );

2. Advanced Usage
This example shows how you can determine if a local copy should be retained based on the name of the feed and a field value in the Entry Object.
add_filter( 'gform_dropbox_store_local_version_10', 'maybe_store_local_version', 10, 6 );
function maybe_store_local_version( $store_local_version, $file, $field_id, $form, $entry, $feed ) {
if ( rgars( $feed, 'meta/feedName') == 'Dropbox Feed 2' && rgar( $entry, '5' ) == 'No' ) {
return true;
}

return $store_local_version;
}

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
gf_apply_filters( 'gform_dropbox_store_local_version', array( $form['id'], $field_id ), false, $file, $field_id, $form, $entry, $feed )

This filter is located in GFDropbox::upload_file() in class-gf-dropbox.php.

發表回覆

您的電子郵箱地址不會被公開。 必填項已用 * 標註