Critical error caused by frontend form
Support › MB Frontend Submission › Critical error caused by frontend formResolved
- This topic has 4 replies, 3 voices, and was last updated 1 year, 8 months ago by
Scott Brim.
-
AuthorPosts
-
August 11, 2023 at 3:41 PM #42890
Yasmine
ParticipantI have a very long frontend form (all created via the meta box custom fields extension). However, when I add the shortcode - [mb_frontend_form id='research-summary'] on the frontend, then I get a critical error.
I tested a very short test form and did not get an issue. But I get a lot of errors for my long one! Even on a blank page, with all custom code disabled, and all plugins deactivated. I am not sure what to do with them:
[11-Aug-2023 08:34:56 UTC] PHP Fatal error: Uncaught Error: Call to undefined function get_current_screen() in /public_html/wp-admin/includes/template.php:1481
Stack trace:
#0 public_html/wp-content/plugins/meta-box/inc/fields/taxonomy.php(310): remove_meta_box('tagsdiv-type-of...', NULL, 'side')
#1 /public_html/wp-content/plugins/meta-box/inc/fields/taxonomy.php(301): RWMB_Taxonomy_Field::remove_default_meta_box(Array)
#2 /public_html/wp-content/plugins/meta-box/inc/field.php(535): RWMB_Taxonomy_Field::admin_enqueue_scripts(Array)
#3 /public_html/wp-content/plugins/meta-box-aio/vendor/meta-box/meta-box-group/group-field.php(52): RWMB_Field::call(Array, 'admin_enqueue_s...')
#4 /public_html/wp-content/plugins/meta-box/inc/field.php(535): RWMB_Group_Field::admin_enqueue_scripts(Array)
#5 /public_html/wp-admin/includes/template.php on line 1481August 11, 2023 at 5:55 PM #42892Yasmine
ParticipantI had some rogue custom settings and tabs when I looked into my fields, which Ive now stripped all of. So now no obvious 'critical error'. But still the form is not showing, not even with [mb_frontend_form id='research-summary' post_fields='title'] and I am still getting the following errors:
[11-Aug-2023 10:49:46 UTC] PHP Fatal error: Uncaught Error: Call to undefined function get_current_screen() in /public_html/wp-admin/includes/template.php:1481
* @param string $id Meta box ID (used in the 'id' attribute for the meta box). * @param string|array|WP_Screen $screen The screen or screens on which the meta box is shown (such as a * post type, 'link', or 'comment'). Accepts a single screen ID, * WP_Screen object, or array of screen IDs. * @param string $context The context within the screen where the box is set to display. * Contexts vary from screen to screen. Post edit screen contexts * include 'normal', 'side', and 'advanced'. Comments screen contexts * include 'normal' and 'side'. Menus meta boxes (accordion sections) * all use the 'side' context. */ function remove_meta_box( $id, $screen, $context ) { global $wp_meta_boxes; if ( empty( $screen ) ) { $screen = get_current_screen(); // This is line 1481 } elseif ( is_string( $screen ) ) { $screen = convert_to_screen( $screen ); } elseif ( is_array( $screen ) ) { foreach ( $screen as $single_screen ) { remove_meta_box( $id, $single_screen, $context ); } } if ( ! isset( $screen->id ) ) { return; } $page = $screen->id; if ( ! isset( $wp_meta_boxes ) ) { $wp_meta_boxes = array(); } if ( ! isset( $wp_meta_boxes[ $page ] ) ) { $wp_meta_boxes[ $page ] = array(); } if ( ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) { $wp_meta_boxes[ $page ][ $context ] = array(); } foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { $wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ] = false; } }
Stack trace:
#0 /public_html/wp-content/plugins/meta-box/inc/fields/taxonomy.php(310): remove_meta_box('tagsdiv-type-of...', NULL, 'side')
#1 /public_html/wp-content/plugins/meta-box/inc/fields/taxonomy.php(301): RWMB_Taxonomy_Field::remove_default_meta_box(Array)
#2 /public_html/wp-content/plugins/meta-box/inc/field.php(535): RWMB_Taxonomy_Field::admin_enqueue_scripts(Array)
#3 /public_html/wp-content/plugins/meta-box-aio/vendor/meta-box/meta-box-group/group-field.php(52): RWMB_Field::call(Array, 'admin_enqueue_s...')
#4 /public_html/wp-content/plugins/meta-box/inc/field.php(535): RWMB_Group_Field::admin_enqueue_scripts(Array)
#5 /public_html/wp-admin/includes/template.php on line 1481August 11, 2023 at 9:35 PM #42899Peter
ModeratorHello,
If you have
taxonomy
ortaxonomy_advanced
field in the field group and use the Gutenberg editor (not Classic Editor), please disable the option "Remove default meta box" and check this issue again.
Screenshot https://imgur.com/7JjuY7YAugust 12, 2023 at 1:12 AM #42901Yasmine
ParticipantThank you so much! It was on in one field and now it populates!
However, still getting this error: [11-Aug-2023 18:11:15 UTC] PHP Notice: Array to string conversion in /home/customer/www/domain/public_html/wp-content/plugins/elementor/includes/utils.php on line 506
However, I am in the process of migrating away from elementor to Bricks, and so it's not an issue for me. just letting you know!
August 16, 2023 at 7:11 PM #42934Scott Brim
ParticipantDisabling 'Remove default meta box' worked for me (thank you!), but I request that you protect against this error. Apparently the fix (gleaned from stackexchange) is to insert
require_once(ABSPATH . 'wp-admin/includes/screen.php');
before calling get_current_screen. -
AuthorPosts
- You must be logged in to reply to this topic.