WPForms: hide certain sections on a single entry page: notes, log, debug, meta, payment, actions, related, geolocation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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