Forked from Shelob9/caldera_forms_api_allow_entry_view-1.php
Last active
October 18, 2019 10:31
-
-
Save New0/f9c3aaad364fdc9d6bf4af117f55597c to your computer and use it in GitHub Desktop.
Code examples for caldera_forms_api_allow_entry_view filter to change who can see Caldera Forms front-end entry viewer and corresponding REST API endpoint
This file contains hidden or 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 | |
/** | |
* Allow all requests to read entries of form with ID CF123567 | |
* | |
* For API endpoint that powers front-end entry viewer. | |
*/ | |
add_filter( 'caldera_forms_api_allow_entry_view', function( $allowed, $form_id, WP_REST_Request $request ){ | |
if( 'CF123567' === $form_id ){ | |
return true; | |
} | |
return $allowed; | |
}, 10, 3 ); |
This file contains hidden or 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 | |
/** | |
* Custom auth for requests to read entries of form with ID CF123567 | |
* | |
* For API endpoint that powers front-end entry viewer. | |
*/ | |
add_filter( 'caldera_forms_api_allow_entry_view', function( $allowed, $form_id, WP_REST_Request $request ){ | |
if( 'CF123567' === $form_id ){ | |
//Create your own system for checking authorization, using current request. | |
$allowed = some_custom_auth_function( $request ); | |
} | |
return $allowed; | |
}, 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment