Created
January 29, 2015 15:38
-
-
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
This file contains 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 | |
/** | |
* 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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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