Skip to content

Instantly share code, notes, and snippets.

@saifsultanc
Created April 14, 2025 09:39
Show Gist options
  • Save saifsultanc/5569cbaba74cde2204babe12637e0b92 to your computer and use it in GitHub Desktop.
Save saifsultanc/5569cbaba74cde2204babe12637e0b92 to your computer and use it in GitHub Desktop.
test.php
<?php
add_action( 'gform_entry_post_save', function( $entry ) {
$form = GFAPI::get_form( $entry['form_id'] );
foreach ( $form['fields'] as $field ) {
if ( $field->get_input_type() === 'html' ) {
// Save HTML field content into entry meta
gform_update_meta( $entry['id'], 'html_field_' . $field->id, $field->content );
}
}
}, 99, 1 );
add_filter( 'gform_entry_detail_meta_boxes', function( $meta_boxes, $entry, $form ) {
$html_output = '';
foreach ( $form['fields'] as $field ) {
if ( $field->get_input_type() === 'html' ) {
$content = gform_get_meta( $entry['id'], 'html_field_' . $field->id );
$content = gp_populate_anything()->live_merge_tags->replace_live_merge_tags_static( $content, $form, $entry );
if ( $content ) {
$html_output .= "<h4>HTML Field {$field->id}</h4><div>{$content}</div><hr>";
}
}
}
if ( $html_output ) {
$meta_boxes[] = array(
'title' => 'HTML Fields',
'callback' => function () use ( $html_output ) {
echo wp_kses_post( $html_output );
},
'context' => 'side',
'priority' => 'low',
);
}
return $meta_boxes;
}, 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment