Last active
November 1, 2019 08:49
-
-
Save New0/cdd4cacbd98cce90edd925a3daa9c7ae to your computer and use it in GitHub Desktop.
Allow all users (non logged-in) to view the Caldera Forms entry for a prcise form.
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 | |
/* | |
* Plugin Name: CF allow all viewers | |
* Author: New0 | |
* Description: Allow all requests to read entries of form with ID CF5c78740daac4a | |
*/ | |
/** | |
* 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 ){ | |
//EDIT FORM ID CF5c78740daac4a | |
if( 'CF5c78740daac4a' === $form_id ){ | |
return true; | |
} | |
return $allowed; | |
}, 10, 3 ); | |
//Change Edition permissions on the form | |
add_filter( 'caldera_forms_manage_cap', function( $allowed, $context, $form ){ | |
//EDIT FORM ID CF5c78740daac4a | |
if( 'CF5c78740daac4a' === $form['ID'] ){ | |
$allowed = "read"; | |
} | |
return $allowed; | |
}, 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment