Skip to content

Instantly share code, notes, and snippets.

@slaFFik
Last active February 10, 2021 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slaFFik/d0ad8624555198a12993214b68718cd3 to your computer and use it in GitHub Desktop.
Save slaFFik/d0ad8624555198a12993214b68718cd3 to your computer and use it in GitHub Desktop.
WPForms: hide certain sections on a single entry page: notes, log, debug, meta, payment, actions, related, geolocation.
<?php
/**
* This code removes all sections on a single entry page in the admin area.
* Methods names in the remove_action() function call are self explanatory.
* Comment out or remove those lines which sections you want to show.
*/
// Main content area.
add_action( 'wpforms_entry_details_content', static function ( $entry, $form_data, $single_entry ) {
$hook_name = 'wpforms_entry_details_content';
remove_action( $hook_name, [ $single_entry, 'details_fields' ], 10 );
remove_action( $hook_name, [ $single_entry, 'details_notes' ], 10 );
remove_action( $hook_name, [ $single_entry, 'details_log' ], 40 );
remove_action( $hook_name, [ $single_entry, 'details_debug' ], 50 );
if ( ! function_exists( 'wpforms_geolocation' ) ) {
return;
}
global $wp_filter;
// Find the Geolocation addon instance and use it to unhook the section.
foreach ( $wp_filter[ $hook_name ]->callbacks as $priority => $callbacks ) {
foreach ( $callbacks as $key => $callback ) {
if (
! $callback['function'] instanceof \Closure &&
$callback['function'][0] instanceof \WPForms_Geolocation &&
$callback['function'][1] === 'entry_details_location'
) {
unset( $wp_filter[ $hook_name ]->callbacks[ $priority ][ $key ] );
}
}
}
}, 0, 3 );
// Sidebar.
add_action( 'wpforms_entry_details_sidebar', static function ( $entry, $form_data, $single_entry ) {
remove_action( 'wpforms_entry_details_sidebar', [ $single_entry, 'details_meta' ], 10 );
remove_action( 'wpforms_entry_details_sidebar', [ $single_entry, 'details_payment' ], 15 );
remove_action( 'wpforms_entry_details_sidebar', [ $single_entry, 'details_actions' ], 20 );
remove_action( 'wpforms_entry_details_sidebar', [ $single_entry, 'details_related' ], 20 );
}, 0, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment