How to make sure plugin code doesn't run on login screen

I have a chunk of plugin code that works fine when on the admin pages, but errors out terribly when on the login page. Is there any way to tell if I’m running in the login screen and bypass a chunk of code?

Here’s what’s erroring out:

// Add the menu
// all this will need to move into the form function soon enough.
ob_start(); // use this to turn off output buffering so the zp_ui_form_process function can work without headers
add_action('admin_menu', 'zp_add_debug_menu'); // Hook for adding admin menus
if (!isset($_POST['zp_handle_form'])) {
ob_end_flush(); // but, if we're not in the form processing code, turn it off

  • Aaron
    • CTO

    You can do a strpos() on one of the $_SERVER variables or check the $current_screen global (it’s an object, do a print_r() to see what it shows).


    stdClass Object


    [id] => product

    [base] => post

    [post_type] => product

    [parent_file] => edit.php?post_type=product

    [parent_base] => edit


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.