Using Gravity Forms ‘gform_pre_entry_detail’ PHP action

The gform_pre_entry_detail Gravity Forms action fires before the entry detail page is displayed.

Usage

add_action('gform_pre_entry_detail', 'your_function_name', 10, 2);

Parameters

  • $form (Form Object): The current form.
  • $entry (Entry Object): The current entry.

More information

See Gravity Forms Docs: gform_pre_entry_detail

This action was added in Gravity Forms version 2.3.3.9. It is located in GFEntryDetail::lead_detail_page in entry_detail.php.

Examples

Display a message before entry detail

Display a “Hello, World!” message before the entry detail page.

add_action('gform_pre_entry_detail', 'display_hello_message', 10, 2);
function display_hello_message($form, $entry) {
  echo '**Hello, World!**';
}

Show a custom message for a specific form

Display a custom message for a specific form with ID 5.

add_action('gform_pre_entry_detail', 'display_custom_message', 10, 2);
function display_custom_message($form, $entry) {
  if ($form['id'] == 5) {
    echo '**Welcome to Form 5!**';
  }
}

Display entry submission date

Show the submission date of the entry before the entry detail page.

add_action('gform_pre_entry_detail', 'display_submission_date', 10, 2);
function display_submission_date($form, $entry) {
  echo '**Submitted on: ' . $entry['date_created'] . '**';
}

Display entry field value

Show the value of a specific field with ID 3 from the entry.

add_action('gform_pre_entry_detail', 'display_field_value', 10, 2);
function display_field_value($form, $entry) {
  $field_id = 3;
  echo '**Field ' . $field_id . ' Value: ' . $entry[$field_id] . '**';
}

Change background color based on entry status

Change the background color of the entry detail page based on the entry status.

add_action('gform_pre_entry_detail', 'change_background_color', 10, 2);
function change_background_color($form, $entry) {
  $bg_color = ($entry['status'] == 'approved') ? '#DFF0D8' : '#F2DEDE';
  echo '<style>body { background-color: ' . $bg_color . '; }</style>';
}