Last active
October 16, 2020 01:00
-
-
Save zackkatz/ce64a08a01f7209ff05422f9dcfa4749 to your computer and use it in GitHub Desktop.
GravityView - Modify Field Settings to always have some settings checked
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Run after 10 priority to make sure all the fields are added | |
add_filter( 'gravityview_template_field_options', 'gv_modify_field_setting_defaults', 20, 6 ); | |
/** | |
* Always check "Show Label" and "Visible to Logged-in Viewers" field settings | |
* | |
* @param array $field_options Array of field options with `label`, `value`, `type`, `default` keys | |
* @param string $template_id Table slug | |
* @param float $field_id GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by` | |
* @param string $context What context are we in? Example: `single` or `directory` | |
* @param string $input_type (textarea, list, select, etc.) | |
* @param int $form_id The form ID. @since develop | |
* | |
* @return array Modified field settings | |
*/ | |
function gv_modify_field_setting_defaults( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { | |
if ( isset( $field_options['show_label'] ) ) { | |
$field_options['show_label']['value'] = true; | |
} | |
if ( isset( $field_options['only_loggedin'] ) ) { | |
$field_options['only_loggedin']['value'] = true; | |
} | |
return $field_options; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment