Title: get_current_screen() throws &#039;undefined function&#039; error
Last modified: August 21, 2016

---

# get_current_screen() throws 'undefined function' error

 *  Resolved [Christiaan Conover](https://wordpress.org/support/users/cconover/)
 * (@cconover)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/get_current_screen-throws-undefined-function-error/)
 * I’m trying to use the [get_current_screen()](http://codex.wordpress.org/Function_Reference/get_current_screen)
   function in my plugin, but I’m getting an “undefined function” error from PHP
   when I do. I looked around to see if that function was deprecated but it doesn’t
   appear to be. Any suggestions on how to resolve this?
 * You can see the error at [https://wp.dev.cconover.com/](https://wp.dev.cconover.com/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/get_current_screen-throws-undefined-function-error/#post-4340460)
 * I believe this function can only be used for admin screens in the backend, the
   page it is defined on is not loaded for front end requests. While this appears
   to be the case, I can’t find definitive evidence at the moment.
 *  Thread Starter [Christiaan Conover](https://wordpress.org/support/users/cconover/)
 * (@cconover)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/get_current_screen-throws-undefined-function-error/#post-4340462)
 * I moved the call inside my plugin file that’s only loaded when inside wp-admin,
   and now the error only loads inside wp-admin.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/get_current_screen-throws-undefined-function-error/#post-4340541)
 * So much for that idea. Is your script run due to an external request (link clicked),
   or is it in an action or filter hook? Are you able to call other WordPress functions
   in this context without error?
 * It’s sounding like an external request where the WordPress environment is not
   loaded. There’s a few options to deal with this, one is to make an AJAX request
   instead of using a simple link.
 *  Thread Starter [Christiaan Conover](https://wordpress.org/support/users/cconover/)
 * (@cconover)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/get_current_screen-throws-undefined-function-error/#post-4340542)
 * You can see the script where I’m using it here: [https://github.com/cconover/wp-author-customization/blob/dev/author-customization/admin/author-customization-admin.php](https://github.com/cconover/wp-author-customization/blob/dev/author-customization/admin/author-customization-admin.php)
 * That’s the main admin script for my plugin. It’s called by the main plugin script
   only when inside WordPress admin, which you can see here: [https://github.com/cconover/wp-author-customization/blob/dev/author-customization/author-customization.php](https://github.com/cconover/wp-author-customization/blob/dev/author-customization/author-customization.php)
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/get_current_screen-throws-undefined-function-error/#post-4340571)
 * You’re executing the function when the plugin code is loaded which is way too
   early. The function needs to be called from some action hook, perhaps ‘admin-
   init’.
 * If you must know what page is being loaded that early, maybe you can use `$_SERVER['
   REQUEST_URI']`?
 *  Thread Starter [Christiaan Conover](https://wordpress.org/support/users/cconover/)
 * (@cconover)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/get_current_screen-throws-undefined-function-error/#post-4340572)
 * Ok, thanks. I figured that since the script it’s in is only called once inside
   admin it would be sufficient. I’ll try your suggestion, thanks!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘get_current_screen() throws 'undefined function' error’ is closed to 
new replies.

## Tags

 * [get_current_screen](https://wordpress.org/support/topic-tag/get_current_screen/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 6 replies
 * 2 participants
 * Last reply from: [Christiaan Conover](https://wordpress.org/support/users/cconover/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/get_current_screen-throws-undefined-function-error/#post-4340572)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
