WordPress.org

Ready to get started?Download WordPress

Forums

Insufficient priveledges on Admin Options when loaded from another file? (19 posts)

  1. Rev. Voodoo
    Volunteer Moderator
    Posted 3 years ago #

    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:
    http://wordpress.pastebin.com/JfHenY4w

    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!

  2. Mark / t31os
    Moderator
    Posted 3 years ago #

    I assume you left something out of the paste, it's missing the opening PHP tag at the top of the file..

    <?php
  3. Rev. Voodoo
    Volunteer Moderator
    Posted 3 years ago #

    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

  4. Mark / t31os
    Moderator
    Posted 3 years ago #

    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).

  5. Rev. Voodoo
    Volunteer Moderator
    Posted 3 years ago #

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

    <?php
    // ADD OUR ADMIN THEME AND CUSTOM LOGOS
    require_once ( get_stylesheet_directory() . '/admin-theme.php' );
    
    // BRING IN THE THEME OPTIONS PAGE
    require_once ( get_stylesheet_directory() . '/admin-options.php' );
    
    more code, etc
  6. Mark / t31os
    Moderator
    Posted 3 years ago #

    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... :)

  7. Rev. Voodoo
    Volunteer Moderator
    Posted 3 years ago #

    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!

  8. Mark / t31os
    Moderator
    Posted 3 years ago #

    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?

  9. Rev. Voodoo
    Volunteer Moderator
    Posted 3 years ago #

    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!

  10. Rev. Voodoo
    Volunteer Moderator
    Posted 3 years ago #

    Here's the theme

    I'll play around with debugging.....

  11. Mark / t31os
    Moderator
    Posted 3 years ago #

    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..

  12. Rev. Voodoo
    Volunteer Moderator
    Posted 3 years ago #

    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

  13. Rev. Voodoo
    Volunteer Moderator
    Posted 3 years ago #

    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)

  14. Mark / t31os
    Moderator
    Posted 3 years ago #

    I have no errors with debug on ... :P

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

  15. Rev. Voodoo
    Volunteer Moderator
    Posted 3 years ago #

    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!! :P

  16. Mark / t31os
    Moderator
    Posted 3 years ago #

    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 ... ;)

  17. Rev. Voodoo
    Volunteer Moderator
    Posted 3 years ago #

    ooh, thanks for whatever you fix on my theme! I'm sure it's a mess....I piece things together as I find/half understand it!

    I slowly clean things up as I learn....so any help you give is soooooooo appreciated!!!

  18. Mark / t31os
    Moderator
    Posted 3 years ago #

    Been putting most of my attention on getting your options all working using a single option field (ie. one row in the options table), and filtering each option correctly (eg. esc_url for options that expect URLs, wp_kses for text only, and so on..), couldn't leave you using 40 seperate options, that would be criminal.. :)

    Replaced various functions for upto date counter-parts, for example get_setting is deprecated, so switched calls over to get_option, likewise for calls to get_links, and various other functions dotted around the theme files..

    Have no idea how any of these changes will work out for you, so i'm going to rename the theme and the functions, so you can install it as a secondary theme and test it (don't overwrite your existing one, keep that as a backup incase something doesn't quite work right).

    Just want to minimize the possible problems before giving you anything... so watch this space... ;)

  19. Rev. Voodoo
    Volunteer Moderator
    Posted 3 years ago #

    So very much appreciated. I'm sure I'll learn a fair bit once you are done and I read through it. Everything is so pieced together from all over the webs.... I'm just starting to learn what everything does... ;)

Topic Closed

This topic has been closed to new replies.

About this Topic