Skip to content

Instantly share code, notes, and snippets.

@New0
Last active November 1, 2019 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save New0/cdd4cacbd98cce90edd925a3daa9c7ae to your computer and use it in GitHub Desktop.
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.
<?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