説明
について wpforms_google_drive_provider_settings_form_builder_enabled_shared_drives
Googleアカウントの共有ドライブフォルダからディレクトリを表示できます。
パラメータ
パラメータ | タイプ | 説明 |
---|---|---|
$form | object | すべてのフォーム設定とフィールドを含む WP_Post オブジェクト。 |
$is_enabled | bool | Google Drive プロバイダで共有ドライブを有効にするかどうかを指定するブール値。 |
ソース
wpforms-google-drive/src/Provider/Settings/FormBuilder.php
詳細情報
このフィルタを使用すると、Google Drive アドオンをサイトのフォームに接続する際に、共有フォルダからディレクトリを選択することができます。このフィルタはフォームビルダのインターフェイスで Google Drive との統合を有効にするか無効にするかを制御します。
例
/**
* 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' );
上のスニペットは、ウェブサイト上のすべてのフォームにこの機能を適用します。特定のフォームにフィルタを適用したい場合は、以下のスニペットを使用してください:
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 );
上のスニペットの123を実際のフォーム ID に置き換えてください。フォームIDの取得方法についてはチュートリアルをご覧ください。