Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Shelob9/a516ed994e8cbecef247c2aa4ff67125 to your computer and use it in GitHub Desktop.
Save Shelob9/a516ed994e8cbecef247c2aa4ff67125 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
<?php
/**
* Allow all requests to read entries of form with ID CF123567
*
* For API endpoint that powers front-end entry viewer.
*/
apply_filters( 'caldera_forms_api_allow_entry_view', function( $allowed, $form_id, WP_REST_Request $request ){
if( 'CF123567' ===$form_id ){
return true;
}
return $allowed;
}, 10, 3 );
<?php
/**
* Custom auth for requests to read entries of form with ID CF123567
*
* For API endpoint that powers front-end entry viewer.
*/
apply_filters( '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 );
@New0
Copy link

New0 commented Oct 18, 2019

I forked this Gist to update the doc post at - https://calderaforms.com/doc/caldera_forms_api_allow_entry_view/ - the gist uses "apply_filters" when it should use "add_filter"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment