I've got a button in theme options that calls a file called color.php, (the contents of which are below).

On certain installations of the theme, the script is generating a 404 error and failing unless I take out everything above the //do something line. Any suggestions on what might be causing it?


if (!is_user_logged_in()){
    die("You Must Be Logged In to Access This");
if( ! current_user_can('edit_files')) {
    die("Oops sorry you are not authorized to do this");
 //do something
  • If you hardcode the url does it still 404? If so , use a proper pathing for your require.
    – Wyck
    May 28, 2011 at 3:08
  • Yes, according to chrome developer tools, it does.
    – Scott B
    May 29, 2011 at 22:25

1 Answer 1


It is not a 404 error, it’s a server error. You are calling is_user_logged_in and current_user_can probably before the definition is loaded. Hook your check to an action where these functions are known, admin_init for example.

  • Thanks toscho, chrome developer tools is reporting it as a "404 error". I'll try your suggestion: add_action( 'admin_init', 'function_name' );
    – Scott B
    May 29, 2011 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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