Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zackkatz/ecf25bc35c026e617488 to your computer and use it in GitHub Desktop.
Save zackkatz/ecf25bc35c026e617488 to your computer and use it in GitHub Desktop.
GravityView - Modify the content returned from the Custom Content field
<?php
/** Modify the content returned from the Custom Content field */
add_filter( 'gravityview/fields/custom/content_before', 'my_gv_custom_content_before', 10, 2 );
/**
* 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
* @param \GV\Template_Context $context
* @return string
*/
function my_gv_custom_content_before( $content, $context = null ) {
$id = 'MY_FIELD_ID';
if( empty( $context->entry["{$id}"] ) ) {
return '';
}
return $content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment