Using Gravity Forms ‘gform_dropbox_folder_path’ PHP filter

The gform_dropbox_folder_path filter allows you to override the destination folder configured on the Dropbox feed for Gravity Forms.

Usage

To apply the filter to all forms, use:

add_filter('gform_dropbox_folder_path', 'your_function_name', 10, 5);

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

add_filter('gform_dropbox_folder_path_10', 'your_function_name', 10, 5);

Parameters

  • $folder_path (string) – The folder in the Dropbox account where the files will be stored, e.g., /local.wordpress.dev.
  • $form (Form Object) – The form currently being processed.
  • $field_id (string) – The ID of the field currently being processed.
  • $entry (Entry Object) – The entry currently being processed.
  • $feed (Feed Object) – The feed currently being processed.

More information

See Gravity Forms Docs: gform_dropbox_folder_path

Examples

Use an entry value in the destination path

This example demonstrates how to use a field value from the Entry Object when modifying the path:

add_filter('gform_dropbox_folder_path_10', 'change_path', 10, 5);

function change_path($folder_path, $form, $field_id, $entry, $feed) {
    return $folder_path . '/' . rgar($entry, '5');
}

Place this code in the functions.php file of your active theme.

Change folder path based on user role

This example changes the destination folder based on the current user’s role:

add_filter('gform_dropbox_folder_path', 'change_path_based_on_role', 10, 5);

function change_path_based_on_role($folder_path, $form, $field_id, $entry, $feed) {
    $user = wp_get_current_user();
    if (in_array('administrator', $user->roles)) {
        return $folder_path . '/administrators';
    }
    return $folder_path . '/users';
}

Change folder path based on form title

This example changes the destination folder based on the form’s title:

add_filter('gform_dropbox_folder_path', 'change_path_based_on_form_title', 10, 5);

function change_path_based_on_form_title($folder_path, $form, $field_id, $entry, $feed) {
    return $folder_path . '/' . sanitize_title($form['title']);
}

Change folder path based on entry date

This example changes the destination folder based on the entry’s date:

add_filter('gform_dropbox_folder_path', 'change_path_based_on_entry_date', 10, 5);

function change_path_based_on_entry_date($folder_path, $form, $field_id, $entry, $feed) {
    $entry_date = date('Y-m', strtotime($entry['date_created']));
    return $folder_path . '/' . $entry_date;
}