WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] "Cheatin' Uh?" - Editor Accessible Settings Page (19 posts)

  1. mywebgrocer
    Member
    Posted 3 years ago #

    Please be assured I've done a fair amount of searching and have only found outdated and unsolved posts on this topic.

    I want to give my editors access to a custom settings page which I created with the following line of code:

    add_menu_page('Theme Settings', 'Theme Settings', 'edit_pages', basename(__FILE__), 'my_settings_page', get_bloginfo('template_directory') . '/images/icon_16.png');

    This gives them access to the page (link shows up in menu) but when they try to save the settings, the infamous "Cheatin' uh?" message is displayed. I've tried finding a capabilities manager plugin to give access but no luck for custom pages.

    Most of the posts I found on the topic were for very old versions of WP and I'm hoping the issue has a solution in 3.0.4 (or 3.1?).

    Any help is appreciated.

    Thanks

  2. mywebgrocer
    Member
    Posted 3 years ago #

    I've tried several capability/role manager plugins with no luck. With Capability Manager, I created a custom capability called

    manage_custom_settings

    and used it like this:

    add_menu_page('Theme Settings', 'Theme Settings', 'manage_custom_settings', basename(__FILE__), 'my_settings_page', get_bloginfo('template_directory') . '/images/icon_16.png');

    Any ideas?

  3. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    You need to use the correct capability.

    Try "edit_theme_options":

    add_menu_page('Theme Settings', 'Theme Settings', 'edit_theme_options', basename(__FILE__), 'my_settings_page', get_bloginfo('template_directory') . '/images/icon_16.png');

    If that doesn't work, then you need to choose a capability available to users with the "Editor" role, or else use a capability/role manager plugin to give the "Editor" role the "edit_theme_options" capability.

  4. mywebgrocer
    Member
    Posted 3 years ago #

    Thanks for your reply. I tried giving the capability

    edit_theme_options

    to editors via Capability Manager but I am still getting the "Cheatin'" message when trying to save... I can see the menu item, get to the page, but can't update options. I also tried edit_themes but no luck. It appears to work only when I give the full manage_options capability... but that is far too much power to give to my editors.

    It seems there is something preventing the full permission of updating the settings even though the user has the capability required by the page (edit_theme_options).

  5. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    Long shot, but can you try using add_theme_page() rather than add_menu_page()?

  6. mywebgrocer
    Member
    Posted 3 years ago #

    And line 30 of wp-admin/options.php says it all:

    if ( !current_user_can('manage_options') )

    This is preventing saving any options without the manage_options capability. If only there were a hook here to make an exception for certain options...

  7. mywebgrocer
    Member
    Posted 3 years ago #

    And yes, I switched to using the add_theme_page

  8. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    Something else is going on here.

    There are many, many Themes (including my own) that use the "edit_theme_options" capability for Theme Settings pages, with no issues whatsoever.

  9. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    What are you doing on submit of your Settings page form?

  10. mywebgrocer
    Member
    Posted 3 years ago #

    I built my options page just as this example (which was linked from a codex article).

    I'm sure there are many themes using these features but the problem is that I need an Editor to be able to use it... from that line in wp-admin/options.php I can tell that you MUST have the manage_options capability to POST the options form to the options.php page. My solution will be to have the form submit to the page itself (rather than options.php) and I'll process the submission from there.

  11. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    Can you post your entire Theme Options code into a paste bin?

  12. smconner
    Member
    Posted 3 years ago #

    Hey mywebgrocer,

    I've recently run into the exact same issue with an options page for my users, and it's causing considerable frustration... I used the same example and I've spent the last two days thoroughly vetting my code with lots of little "echo hey I'm here" type statements, and as near as I can tell it should be working for users with non-administrator privileges, but it ain't.

    So I figure either my understand is flawed (probable), the code is flawed (possible) or there's a hole in the universe that's sucking non-administrative permissions into it.

    ...I notice you haven't posted for a couple weeks. Does this mean you found a solution? (Please oh please fulfill my daylight-savings day wish!)

  13. smconner
    Member
    Posted 3 years ago #

    I think I may have figured out my own issue... I think I was using kind of a bastardized way of getting input from the menu in to the options database, i.e. by posting to options.php:

    ?>
    		<form action="options.php" method="post">
    			<?php settings_fields($report_user_input); ?>
    			<?php do_settings_sections(__FILE__); ?>
    			<p class="submit">
    				<input name="Submit" type="submit" class="button-primary" value="<?php esc_attr_e('Save Changes'); ?>" />
    			</p>
    		</form>
    
    	<?php

    But I think this is the way to do it (i.e. the examples: Sample Menu Page) http://codex.wordpress.org/Administration_Menus

    Hope this works for me!

  14. smconner
    Member
    Posted 3 years ago #

    Yep, that was it! SWEET!

  15. maorb
    Member
    Posted 3 years ago #

    Hi,

    I have this exact issue and I use the new settings API to create options page for my users.
    I am using Otto's great tutorial for this and the form must POST to options.php in order to save the options to the database, when using the settings API.

    Solution of @smconner to use the administration menu solves this, but wouldn't let use the settings API, but use the old way of administration menus.

    So, it appears that editor must have manage_options capability to save the settings, but of course I don't want to grant editor this capability.

    If any ideas about that, I will be happy ...

    Thanks
    Maor

  16. ashblue
    Member
    Posted 3 years ago #

    Stuck on this too and a bump for maorb's post.

  17. Ashblue - since this post is marked as Resolved I'd suggest that you start a new thread so more people will see it. You can link to this post within your message for reference.

  18. maorb
    Member
    Posted 3 years ago #

    You can also follow ticket #14365 on trac about this issue.

  19. ashblue
    Member
    Posted 3 years ago #

    Since a new issue has spawned out of thread marked resolved please visit the link below for continued support/solutions on this. Please post new information there too.

    http://wordpress.org/support/topic/wordpress-settings-api-cheatin-uh-error?replies=0

Topic Closed

This topic has been closed to new replies.

About this Topic