Skip to content

Instantly share code, notes, and snippets.

@luistinygod
Created January 29, 2015 15:38
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 luistinygod/8d9ded0fbdc0d16a4f29 to your computer and use it in GitHub Desktop.
Save luistinygod/8d9ded0fbdc0d16a4f29 to your computer and use it in GitHub Desktop.
GravityView: Do not allow to edit a field if the field has a specific value
<?php
/**
* Do not allow a certain user to edit a field if that field has a specific value
*
* Replace the following to your own values:
* - REPLACE_BY_FORM_ID, use the form id where this logic applies
* - REPLACE_BY_FIELD_ID, use the field id where this logic applies
*
*
* Add this gist to your theme functions.php
*
*/
add_filter( 'gravityview_edit_entry_field_content', 'my_gv_custom_edit_fields', 10, 5 );
function my_gv_custom_edit_fields( $content, $field, $value, $entry_id, $form_id ) {
if( $form_id != 'REPLACE_BY_FORM_ID' || $field['id'] != 'REPLACE_BY_FIELD_ID' ) {
return $content;
}
// check for the not possible to change value
if( $value === true ) {
return '';
} else {
return $content;
}
}
@itmaximus
Copy link

Hi,

if I want to the certain fields not be to editable but can still be visible how can I achieve that, or there is a way to show the single entry table in the edit screen?

thanks for your help

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