Using Gravity Forms ‘gform_dropbox_link_type’ PHP filter

The gform_dropbox_link_type filter allows you to change the type of link returned by Dropbox in Gravity Forms.

Usage

A generic example for all forms:

add_filter('gform_dropbox_link_type', 'your_function_name', 10, 3);

To target a specific form, append the form ID to the hook name:

add_filter('gform_dropbox_link_type_10', 'your_function_name', 10, 3);

To target a specific field, append both the form ID and the field ID to the hook name:

add_filter('gform_dropbox_link_type_10_3', 'your_function_name', 10, 3);

Parameters

  • $linkType (string) – The Dropbox link type. Possible values: preview (a preview link to the document for sharing) or direct (an expiring link to download the contents of the file). Default: preview.
  • $form (Form Object) – The form currently being processed.
  • $field_id (string) – The ID of the field currently being processed.

More information

See Gravity Forms Docs: gform_dropbox_link_type

Examples

This code changes the Dropbox link type to ‘direct’ for form ID 10:

add_filter('gform_dropbox_link_type_10', 'change_link_type', 10, 3);
function change_link_type($linkType, $form, $field_id) {
    return 'direct';
}

This code changes the Dropbox link type to ‘direct’ for form ID 10 and field ID 3:

add_filter('gform_dropbox_link_type_10_3', 'change_link_type_for_field', 10, 3);
function change_link_type_for_field($linkType, $form, $field_id) {
    return 'direct';
}

This code changes the Dropbox link type to ‘direct’ for forms with the title “Private Form”:

add_filter('gform_dropbox_link_type', 'change_link_type_based_on_title', 10, 3);
function change_link_type_based_on_title($linkType, $form, $field_id) {
    if ($form['title'] == 'Private Form') {
        return 'direct';
    }
    return $linkType;
}

This code changes the Dropbox link type to ‘direct’ for fields of type ‘fileupload’:

add_filter('gform_dropbox_link_type', 'change_link_type_for_fileupload', 10, 3);
function change_link_type_for_fileupload($linkType, $form, $field_id) {
    $field = GFFormsModel::get_field($form, $field_id);
    if ($field->type == 'fileupload') {
        return 'direct';
    }
    return $linkType;
}