Last active
May 1, 2020 16:13
-
-
Save luistinygod/9dce30ca1fd146dd31bc to your computer and use it in GitHub Desktop.
GravityView: Removes Custom Content field content in case a certain entry's field is empty
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 | |
/** Modify the content returned from the Custom Content field */ | |
add_filter( 'gravityview/fields/custom/content_before', 'my_gv_custom_content_before', 10, 1 ); | |
/** | |
* Removes the custom content field's content in case a certain entry field is empty | |
* Replace the MY_FIELD_ID by the field id (check it on the Gravity Forms form definition) | |
* | |
* @param string $content Custom Content field content | |
* @return string | |
*/ | |
function my_gv_custom_content_before( $content ) { | |
$id = 'MY_FIELD_ID'; | |
global $gravityview_view; | |
extract( $gravityview_view->field_data ); | |
if( empty( $entry[ (string)$id ] ) ) { | |
return ''; | |
} | |
return $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment