-
-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fatal error if not logged in and accessing wp-admin #4828
Comments
I believe the better fix would be:
|
@tanthammar and @therealgilles I'm actually not able to reproduce this error locally. If I attempt to access the wp-admin and I'm not logged in, I'm re-routed to the login screen. Is that not the case with your installations? There is a reason we ask for Steps to Reproduce (for bugs). Your issue overview is not sufficient enough to reproduce the bug. |
Additional forum post for reference from @therealgilles https://wordpress.org/support/topic/problem-with-ajax-requests/ |
In my case, I am using the login-with-ajax plugin. Therefore I am guessing that it's an ajax request that's creating the problem. When doing an ajax request, is_admin() returns true. I also read this from the get_current_screen page:
So again I reckon it would be better to qualify the if statement by checking if the function is defined when the code is reached. |
PR: #4947 |
Issue Overview
I forgot to log in and tried to access wp-admin.
This caused a fatal error.
Expected Behavior
No error
Current Behavior
Fatal error: Uncaught Error: Call to undefined function get_current_screen() in /home/bokamark/staging.bokamarknad.se/wp-content/plugins/pods/classes/PodsInit.php:304 Stack trace: #0 /home/bokamark/staging.bokamarknad.se/wp-includes/class-wp-hook.php(286): PodsInit->register_assets(‘’) #1 /home/bokamark/staging.bokamarknad.se/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array) #2 /home/bokamark/staging.bokamarknad.se/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #3 /home/bokamark/staging.bokamarknad.se/wp-includes/script-loader.php(1435): do_action(‘wp_enqueue_scri...‘) #4 /home/bokamark/staging.bokamarknad.se/wp-includes/class-wp-hook.php(286): wp_enqueue_scripts(‘’) #5 /home/bokamark/staging.bokamarknad.se/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array) #6 /home/bokamark/staging.bokamarknad.se/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #7 /home/bokamark/staging.bokamarknad.se/wp-includes/general-template.php(2614): do_action(‘wp_head’) #8 /home/bokamark/st in /home/bokamark/staging.bokamarknad.se/wp-content/plugins/pods/classes/PodsInit.php on line 304
Possible Solution
Add an if-statement to check if user is logged in.
Update line 304 in Podsinit.php to;
if (is_user_logged_in() && is_admin()) {...}
Steps to Reproduce (for bugs)
See issue Overview
The text was updated successfully, but these errors were encountered: