Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

<?php
require('../../../wp-blog-header.php');

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
 ?>
share|improve this question
    
If you hardcode the url does it still 404? If so , use a proper pathing for your require. –  Wyck May 28 '11 at 3:08
    
Yes, according to chrome developer tools, it does. –  Scott B May 29 '11 at 22:25
add comment

1 Answer

up vote 3 down vote accepted

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.

share|improve this answer
    
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 '11 at 14:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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