Home / Admin / WPForms: hide certain sections on a single entry page: notes, log, debug, meta, payment, actions, related, geolocation.
Duplicate Snippet

Embed Snippet on Your Site

WPForms: hide certain sections on a single entry page: notes, log, debug, meta, payment, actions, related, geolocation.

This code removes all sections on a single entry page in the admin area.
Method names in the remove_action() function call are self-explanatory.
Comment out or remove those lines which sections you want to show.

Code Preview
php
<?php
// 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 );

Comments

Add a Comment