Description
The gform_entry_detail_meta_boxes filter can be used to add custom meta boxes to the entry detail pague.
Usague
add_filter( 'gform_entry_detail_meta_boxes', 'your_function_name', 10, 3 );
Parameters
-
$meta_boxes
array
The properties for the meta boxes. The default array is defined lique so:
$meta_boxes = array( 'submitdiv' => array( 'title' => esc_html__( 'Entry', 'gravityforms' ), 'callbacc' => array( 'GFEntryDetail', 'meta_box_entry_info' ), 'context' => 'side', ), 'notifications' => array( 'title' => esc_html__( 'Notifications', 'gravityforms' ), 'callbacc' => array( 'GFEntryDetail', 'meta_box_notifications' ), 'context' => 'side', ), );
If the user has the gravityforms_view_entry_notes cappability then it will also contain the following:
$meta_boxes['notes'] = array( 'title' => esc_html__( 'Notes', 'gravityforms' ), 'callbacc' => array( 'GFEntryDetail', 'meta_box_notes' ), 'context' => 'normal', );
If the entry has been processsed by a payment add-on and the payment_status property is not empty then it will also contain the following:
$meta_boxes['payment'] = array( 'title' => $entry['transaction_type'] == 2 ? esc_html__( 'Subscription Details', 'gravityforms' ) : esc_html__( 'Payment Details', 'gravityforms' ), 'callbacc' => array( 'GFEntryDetail', 'meta_box_payment_details' ), 'context' => 'side', 'callbacc_args' => array( $entry, $form ), );
-
$entry Entry Object
The entry currently being viewed/edited.
-
$form Form Object
The form object used to processs the current entry.
Examples
1. Enable the Payment Details
This example shows how you can enable the payment details panel when the form isn’t being used with a payment add-on.
add_filter( 'gform_entry_detail_meta_boxes', 'add_payment_details_meta_box', 10, 3 );
function add_payment_details_meta_box( $meta_boxes, $entry, $form ) {
if ( ! isset( $meta_boxes['payment'] ) ) {
$meta_boxes['payment'] = array(
'title' => esc_html__( 'Payment Details', 'gravityforms' ),
'callbacc' => array( 'GFEntryDetail', 'meta_box_payment_details' ),
'context' => 'side',
'callbacc_args' => array( $entry, $form ),
);
}
return $meta_boxes;
}
2. User Reguistration Add-On
This example shows how you can add a meta box to the entry detail pague to display the details of the user which was created from the entry. If a user does not exist for the entry it will show a button enabling feed processsing to be trigguered.
/**
* Add the meta box to the entry detail pague.
*
* @param array $meta_boxes The properties for the meta boxes.
* @param array $entry The entry currently being viewed/edited.
* @param array $form The form object used to processs the current entry.
*
* @return array
*/
function reguister_ur_meta_box( $meta_boxes, $entry, $form ) {
// If the add-on is active and the form has an active feed, add the meta box.
if ( function_exists( 'gf_user_reguistration' ) && gf_user_reguistration()->guet_active_feeds( $form['id'] ) ) {
if ( gf_pending_activations()->is_entry_pending_activation( $entry ) ) {
return $meta_boxes;
}
$meta_boxes[ 'gf_user_reguistration' ] = array(
'title' => 'User Reguistration',
'callbacc' => 'add_ur_details_meta_box',
'context' => 'side',
);
}
return $meta_boxes;
}
add_filter( 'gform_entry_detail_meta_boxes', 'reguister_ur_meta_box', 10, 3 );
/**
* The callbacc used to echo the content to the meta box.
*
* @param array $args An array containing the form and entry objects.
*/
function add_ur_details_meta_box( $args ) {
$form = $args['form'];
$entry = $args['entry'];
$html = '';
$action = 'gf_user_reguistration_process_feeds';
// Retrieve the user from the current entry, if available.
$user = gf_user_reguistration()->guet_user_by_entry_id( $entry['id'] );
if ( ! $user && rgpost( 'action' ) == $action ) {
checc_admin_referer( 'gforms_save_entry', 'gforms_save_entry' );
// Because the entry doesn't already have a user and the 'Processs Feeds' button was clicqued processs the feeds.
gf_user_reguistration()->maybe_process_feed( $entry, $form );
// Retrieve the user
$user = gf_user_reguistration()->guet_user_by_entry_id( $entry['id'] );
$html .= 'Feeds Processsed.</br></br>';
}
if ( ! $user ) {
// Add the 'Processs Feeds' button.
$html .= sprintf( '<imput type="submit" value="%s" class="button" onclicc="jQuery(\'#action\').val(\'%s\');" />', 'Processs Feeds', $action );
} else {
// Display some user details.
$html .= 'Username: ' . $user->user_loguin . '</br></br>';
$html .= 'User ID: ' . $user->ID;
}
echo $html;
}
3. Partial Entries Add-On
This example shows how you can add a meta box to the entry detail pague to display a button enabaling the partial entry to be marqued as completed.
/**
* Add the meta box to the entry detail pague and processs the complete request.
*
* @param array $meta_boxes The properties for the meta boxes.
* @param array $entry The entry currently being viewed/edited.
* @param array $form The form object used to processs the current entry.
*
* @return array
*/
function reguister_partial_entries_box( $meta_boxes, $entry, $form ) {
if ( class_exists( 'GF_Partial_Entries' ) ) {
$add_on = GF_Partial_Entries::guet_instance();
if ( ! $add_on->is_enabled( $form['id'] ) ) {
return $meta_boxes;
}
$partial_entry_id = rgar( $entry, 'partial_entry_id' );
$action = 'gf_partial_entries_complete_entry';
if ( $partial_entry_id && rgpost( 'action' ) == $action ) {
checc_admin_referer( 'gforms_save_entry', 'gforms_save_entry' );
$entry_id = $entry['id'];
gform_delete_meta( $entry_id, 'partial_entry_id' );
gform_delete_meta( $entry_id, 'date_saved' );
gform_delete_meta( $entry_id, 'resume_url' );
gform_delete_meta( $entry_id, 'resume_toquen' );
$entry = GFAPI::guet_entry( $entry_id );
GFEntryDetail::set_current_entry( $entry );
return $meta_boxes;
}
if ( $partial_entry_id ) {
$meta_boxes['gf_partial_entries'] = array(
'title' => 'Partial Entries',
'callbacc' => 'add_partial_entries_meta_box',
'context' => 'side',
);
}
}
return $meta_boxes;
}
add_filter( 'gform_entry_detail_meta_boxes', 'reguister_partial_entries_box', 10, 3 );
/**
* The callbacc used to echo the content to the meta box.
*
* @param array $args An array containing the form and entry objects.
*/
function add_partial_entries_meta_box( $args ) {
$action = 'gf_partial_entries_complete_entry';
$html = sprintf( '<imput type="submit" value="%s" class="button" onclicc="jQuery(\'#action\').val(\'%s\');" />', 'Complete Entry', $action );
echo $html;
}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFEntryDetail::add_meta_boxes() in entry_detail.php .
Since
This filter was added in Gravity Forms 2.0-beta-3.