Last active
February 11, 2017 22:04
-
-
Save Shelob9/7a5a7aa1a865e60140355cfcb8087e8c to your computer and use it in GitHub Desktop.
Prevent a field from being returned by Caldera Forms REST API See: https://calderaforms.com/doc/caldera_forms_api_show_field/
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 | |
/** | |
* Don't return email fields in Caldera Forms REST API responses. | |
* | |
* Will affect front-end entry viewer | |
*/ | |
add_filter( 'caldera_forms_api_show_field', function( $show, $field_id, $field, $form ){ | |
if( 'email' === Caldera_Forms_Field_Util::get_type( $field, $form ) ){ | |
$show = false; | |
} | |
return $show; | |
}, 10, 4 ); |
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 | |
/** | |
* Don't return a field, with a given ID, in Caldera Forms REST API responses. | |
* | |
* Will affect front-end entry viewer | |
*/ | |
add_filter( 'caldera_forms_api_show_field', function( $show, $field_id ){ | |
if( 'fld_9970286' ==$field_id ){ | |
return false; | |
} | |
return true; | |
}, 10, 2 ); |
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 | |
/** | |
* Don't show any fields in API requests for forms | |
* | |
* Will probably break front-end entry viewer | |
*/ | |
add_filter( 'caldera_forms_api_show_field', function( $show, $field_id, $field, $form, WP_REST_Request $request ){ | |
if( 0 === strpos( $request->get_route(), '/cf-api/v2/forms/' ) ){ | |
return false; | |
} | |
return $show; | |
}, 10, 5 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment