• Hi,
    I am trying to code a (at the moment) relatively simple plugin. I’ve got to the point of saving options, and now when I press submit it says error options page not found. I’ve checked and checked and checked the names I’ve entered in all the functions to make sure they seem right (at least what I think is right, as I’m a little confused about the settings API), but can’t find anything.
    So my question:

    Is there a way to see what options it tried to save, etc? I turned on wp_debug as well as wp_debug_log, but nothing is generated other than the error I mentioned.
    I’d give out my code (I plan to release it eventually once it’s in a moderately finished state), but the code is extremely messy (I don’t indent by habit, as I’m blind and it’s just not something I have done from the beginning of my coding career — bad, I know, and I’m trying to fix it– and there are no comments to speak of). I’m trying to learn wordpress plugin coding first, then make it presentable later. xD.
    Thanks,
    -Michael.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    Did you create a new option page or are you adding to an existing one?
    The page should only have one form tag for all options, and the action attribute must be simply action="options.php". No path information.

    Be sure the options.php file on your server actually exists and that its permissions are 644.

    You cannot see what options it tried to save because none were tried at all because the code file to handle the save was not found. All you can check is that the access log indicates a POST to wp-admin/options.php with a 404 result. If the file is not found there is nothing else to go wrong, execution stopped immediately at that error.

    Thread Starter Michael

    (@lilmike)

    Hi,
    I’m thinking we might have a misunderstanding. It’s not a 404, it’s just that it says ‘WordPress error: Options page not found’, which according to the codex means either you are using the wrong name for an option, or page of options, etc. To answer your questions, I am creating a new page of options under the settings menu. The form tag’s action is simply options.php, and the method is post.
    Thanks,
    -Michael.
    P.S. I checked the address bar, and it is indeed going to options.php

    Moderator bcworkz

    (@bcworkz)

    I understand now, my apologies. I’ve never run across that error before, so I became confused. The error text appears to come from options.php itself, line 143. Apparently your options page name is not on a whitelist of allowed pages. Since you are using the API, I would think your page should have been added automatically if all was in order. I’m inclined to believe there is a mismatch or missing name somewhere in your use of the option page name.

    Your best bet is to track down that mismatch. There is a filter for the whitelist called ‘whitelist_options’. If you were to add your option page as a key name in the passed array, that should suffice to suppress the error you see. That does not mean you will not have problems if you have a mismatch, you are only fooling the error trap this way.

    All I can suggest is to check the type and order of the parameters you pass to the various API functions very carefully. Some functions appear to take the same parameters, but they are in a different order, so copy/pasting the same code text gets you in trouble.

    We sighted folk try to consistently organize our code partly because it makes it easier to find discrepancies. I can imagine such organization is less helpful to you, but when you interact with other coders, it’s important that we all organize our code in a similar fashion. It may not directly benefit you, but it will benefit you when you interact with others. I sense you know this, I’m only saying that it may be more important than you realize.

    If your code were in a better state, I could probably help you further. From the sound of it, I don’t think I would be able to spot the problem with your code in it’s current state. I’m not telling you to rewrite your code so I can help you, just that you might try to be more organized from here on out, don’t put it off any longer ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘error: options page not found’ is closed to new replies.