Support » Fixing WordPress » Insufficient priveledges on Admin Options when loaded from another file?

  • Wow, I’ve been running into all sorts of problems this week. And it’s always dumb crap I shoulda noticed. Bad week I guess. But I’m still being dumb, so I’ll ask for help again.

    I would like to clean up my functions.php…so I’m trying to move my admin options stuff from functions.php to it’s own file. When I do, it breaks. The admin menu works great and all options save….. but if I offload it to its own file, and bring it in like this:

    require_once ( get_stylesheet_directory() . '/admin-options.php' );

    The admin menu loads and works, until I try to save. Then I get the ‘You do not have sufficient priviledges’ error

    Any idea what I should change to be able to offload this to its own file?

    Here’s the actual admin menu code:

    I’m not sure if it’s the require once bit I load it in with, or maybe the lines down after 316 where it looks to be saving?

    Thanks once again for helping me understand the stuff I piece together!

Viewing 15 replies - 1 through 15 (of 18 total)
  • I assume you left something out of the paste, it’s missing the opening PHP tag at the top of the file..


    kinda….when it was it’s own standalone file, it had an opening php tag….

    Now that I have it back into my functions.php til I can figure out the permissions issue, I don’t have one, as it’s at the bottom of a slew of other functions…. the opening php tag is waaaaaaaaaay up top above everything else

    I just pulled the relevant admin menu code form my functions.php

    You still need an opening tag in included files, it’s only the closing tag that is optional..

    All PHP files must have an opening tag.. (as far as i’m aware – and unless the file starts with HTML markup, i think).

    I just copied the line from the include, the opening php tag is up above….. there are more includes….. like this:

    require_once ( get_stylesheet_directory() . '/admin-theme.php' );
    require_once ( get_stylesheet_directory() . '/admin-options.php' );
    more code, etc

    Ok no problem, i was just concerned you omitting the opening tag..

    Though isn’t that code above including the admin-options.php file, which is the one i was talking about.. (the one in the pastebin).. maybe i’m lost.. :-s

    You can send me the theme if you like, should only take a few moments to test moving code around… 🙂

    I’ll try to explain… lol, I’m as clear as mud sometimes.

    Originally, the code in the pastebin was in my functions.php file, and it worked fine. Actually both the above require_once bits were in my functions.php. They work great in there. But my functions.php is getting huge. To organize, I offloaded some code to different files.

    First, I moved the admin-theme stuff to admin-theme.php, and called it into functions.php that all worked perfectly.

    So, next up, I tried to move my admin-options to admin-options.php and call that into functions.php.

    When the code in the pastebin is in it’s own file, and being called into functions.php, it won’t work. The admin page will come up, and it will function and look perfect. But as soon as I try to save anything, I get the ‘you do not have sufficient priviledges’ error

    But, if I move the pastebin code from it’s own file, back into functions.php (and remove the require_once statement of course) it works and saves perfectly again.

    Just wondering why it will work from functions.php, but not from it’s own file called into functions.php

    I hope that explained decently? If not I’m happy to package up the theme for you to take a peek, that’s a very nice offer!

    Not sure why that wouldn’t work, you’re welcome to send me the files (or send me a link to get them) whenever you like. I tend to come and go, but i’ll be happy to take a look whenever…

    Out of curiousity have you tried with debugging on?

    I’ve actually never turned debugging on at all! lol…. I should check into that. In the mean time, I’ll get a link to the theme.

    Thanks again!

    Here’s the theme

    I’ll play around with debugging…..

    Preview of the theme is showing me the theme minus CSS, are there any dependancies in the theme that i’m likely to be missing? Any hard-coded paths that won’t match my install, etc..

    Wow, debug mode gets messy!

    Anyway, nothing comes up relevant to the issue. I actually can’t even go into the options page with debug on, just says insufficient permissions…but no errors at all

    still trying to work some things out…. I think you have to go into the themes options menu, and save once….that gets all the defaults loaded/saved properly

    (I don’t know how to make it do that automatically when the theme is activated)

    I have no errors with debug on … 😛

    I’ll activate later and take a look, i’m seeing some incomplete paths if i view the source from the preview frame.. 🙂

    My debug errors are related to 3 plugins…. which I’ll have to look into.

    comment luv, administer, and simple cache

    Crap…more research…thanks!! 😛

    Not sure what was wrong with the way you were trying to manage including the options before, but i hit the same kind of problems, so i started moving pieces of code in small chunks at a time, and it’s all working fine now..

    However, i’ve started messing with all kinds of things, so i’ll zip it up when i get tired of messing with it, you can then test it on a local install or check the code for what i’ve toyed with..


    Don’t worry about the plugin errors too much, not all authors debug their code unfortunately, it will naturally happen with the odd one or two … 😉

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Insufficient priveledges on Admin Options when loaded from another file?’ is closed to new replies.