Heads up!

This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

For extra guidance, please see WPBeginner's tutorial on adding custom code.

Dismiss

Description

The wpforms_google_drive_provider_settings_form_builder_enabled_shared_drives let’s you display directories from shared drive folders on your Google account.

Parameters

ParameterTypeDescription
$formobjectWP_Post object containing all form settings and fields.
$is_enabledboolBoolean to specify whether shared drives are enabled for the Google Drive provider.

Source

wpforms-google-drive/src/Provider/Settings/FormBuilder.php

More Information

This filter allows you to choose directories from shared folders when connecting the Google Drive addon to a form on your site. It controls whether shared drives are enabled or disabled for the Google Drive integration in the form builder interface.

Examples

/**
	* Display shared drives in Google Picker.
	*
    * @link https://wpforms.com/developers/wpforms_google_drive_provider_settings_form_builder_enabled_shared_drives/
	* @since {VERSION}
	*
	* @param bool    $is_enabled Display Shared Drives directories.
	* @param WP_Post $form       Current form.
*/

add_filter( 'wpforms_google_drive_provider_settings_form_builder_enabled_shared_drives', '__return_true' );

The snippet above will apply the functionality to all forms on your website. If you’d like to apply the filter to a specific form, use the snippet below:

function wpf_shared_google_drive_form ( $is_enabled, $form ) {
    // Enable shared drives only for form ID 123
    if ( $form->ID === 123 ) {
        return true;
    }
   
    return $is_enabled;
}

add_filter( 'wpforms_google_drive_provider_settings_form_builder_enabled_shared_drives', 'wpf_shared_google_drive_form', 10, 2 );

Be sure to replace 123 in the snippet above with your actual form ID. See our tutorial if you need help retrieving your form ID.