0

I have a plugin that I wrote. A user was experiencing compatibility problems with a theme of theirs which uses a masked dashboard to add listings on their site. If the user was logged in, and a contributor, but NOT an admin, my check for is_admin() would return true since they were technically on a dashboard page.

So.. my code checks if they are admin, then runs a series of functions. One of the checks is whether or not they have permissions to manage options. If they don't have permissions to manage options, it dies. This is a problem with the theme, so I simply wrapped my add_action tags with the following

if ( is_super_admin() ) {   
    add_action( 'admin_init', 'myplugin_register');
    add_action( 'admin_menu', 'myplugin_menu' );    
}

This throws a 500 error when any admin accesses the wp-admin area of the site. I'm not sure why a simple check to see whether or not the user is a super admin would crash the site.

More info on is_super_admin() here http://codex.wordpress.org/Function_Reference/is_super_admin

  • Looks like a similar issue here wordpress.org/support/topic/… and I know that the function which caused the crash is located in wp_get_current_user() is located in wp-includes/pluggable.php so therefor I should be able to just include that file first, then run my check, correct? – Branndon Oct 3 '13 at 21:22
  • This is my new code. Do you think it'll work? I can't test it as it's on a live website. See code here, as it looked funky in this comment pastebin.com/KNfur9wb – Branndon Oct 3 '13 at 21:25
  • I uploaded this version to test, and again, the admin dashboard threw a 500 error. – Branndon Oct 3 '13 at 21:36
0

From your pastebin:

if (!function_exists('wp_get_current_user')) {
        include_once( ABSPATH . 'wp-admin/includes/pluggable.php' );
}

if ( is_super_admin() ) {      
        add_action( 'admin_init', 'myplugin_register');
        add_action( 'admin_menu', 'myplugin_menu' );   
}

There is no file at wp-admin/includes/pluggable.php. pluggable.php is at wp-includes/pluggable.php, but I see no reason you should have to intentionally include that file. It load front and back end.

  • Right... my mistake. Thanks for pointing it out, and I'll try this tomorrow when the website owner is back online. I can't say why it's not loading automatically, it's part of the theme, and I'm assuming it's not loading all the standard admin stuff. – Branndon Oct 3 '13 at 22:12
  • Errors can trigger a white screen of death depending on configuration. I am hoping that is it. :) – s_ha_dum Oct 3 '13 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.