The gform_entry_detail_content_before action hook allows you to add extra text or sections before the main content on the Entry detail page.
Usage
add_action('gform_entry_detail_content_before', 'add_main_text_before', 10, 2);
Parameters
- $form (Form Object): The form from which the entry value was submitted.
- $entry (Entry Object): The current entry.
More information
See Gravity Forms Docs: gform_entry_detail_content_before
Examples
Add a new section with a header and text
This example adds a new section with a header and text on the Entry detail page.
add_action('gform_entry_detail_content_before', 'add_main_text_before', 10, 2);
function add_main_text_before($form, $entry) {
echo '<table class="widefat fixed entry-detail-view" cellspacing="0"><thead><tr><th>Main Content Before</th></tr></thead><tbody><tr><td>some stuff</td></tr></tbody></table>';
}
Place this code in the functions.php file of your active theme.
Add a custom message before the main content
This example adds a custom message before the main content on the Entry detail page.
add_action('gform_entry_detail_content_before', 'add_custom_message', 10, 2);
function add_custom_message($form, $entry) {
echo '<div class="custom-message">This is a custom message before the main content.</div>';
}
Add a new section with entry data
This example adds a new section displaying the entry’s creation date and the form title.
add_action('gform_entry_detail_content_before', 'add_entry_data_section', 10, 2);
function add_entry_data_section($form, $entry) {
echo '<div class="entry-data-section">';
echo '<p>Form: ' . $form['title'] . '</p>';
echo '<p>Entry Creation Date: ' . $entry['date_created'] . '</p>';
echo '</div>';
}
Display a notice based on a specific form ID
This example displays a notice before the main content only when the form ID is 5.
add_action('gform_entry_detail_content_before', 'display_notice_for_form', 10, 2);
function display_notice_for_form($form, $entry) {
if ($form['id'] == 5) {
echo '<div class="notice">Notice: This is a special form.</div>';
}
}
Add a custom CSS class to the body tag
This example adds a custom CSS class to the body tag on the Entry detail page.
add_action('gform_entry_detail_content_before', 'add_custom_body_class', 10, 2);
function add_custom_body_class($form, $entry) {
echo "<script>document.body.classList.add('custom-entry-detail');</script>";
}