Skip to content

Instantly share code, notes, and snippets.

@New0
Created January 7, 2020 16:24
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/0d9a7f2aaeb1615727ec7af7385b8db6 to your computer and use it in GitHub Desktop.
Save New0/0d9a7f2aaeb1615727ec7af7385b8db6 to your computer and use it in GitHub Desktop.
Allow a precise user to read form the caldera forms entry viewer
<?php
/*
* This will allow a user with ID 2 to view the entry viewer even without the manage_optiuons capability
* REPLACE 2 by the correct user ID
*/
add_filter('caldera_forms_manage_cap', function( $cap, $context, $form ){
if( is_user_logged_in() ){
$user_id = get_current_user_id();
if( $context === "entry-view" && $user_id === 2 ){
$cap = "read";
}
}
return $cap;
}, 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment