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 setup some theme options using this helpful guide as a template. I want to give my editors the option to update these theme options, so I granted the edit_theme_options capability as mentioned here.

However when logged in as an editor I can see the options page, but when I go to save it I get the 'Cheatin uh?' message. I checked the wp-admin/options.php page and the code is:

if ( !current_user_can('manage_options') )
wp_die(__('Cheatin’ uh?'));

So it seems you can't edit options without the manage_options capability, which makes sense. It makes me wonder how you differentiate between general options and theme options. Is there something I've missed?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You should be posting your data (via <form action="" ...> to your theme options page, rather than to the wp-admin/options.php file. The latter is for the stuff under Settings.

Also, I don't mean to be tossing dirt at anyone in particular, but always take the tips that you read on the web with a grain of salt. This post on the same site, as an example, offers extremely bad advice:

http://themeshaper.com/customize-blog-posts-touching-theme-files/

function myblog_shareontwitter($content) {

    print $content; ?>

    <p><a href="http://twitter.com/home?status=Currently reading <?php the_permalink(); ?>" title="Click to send this page to Twitter!" target="_blank">Share <em><?php the_title() ?></em> on Twitter</a></p>

<?php }
add_filter('the_content', 'myblog_shareontwitter');

The above code is completely broken: "the_content" is a filter, WP expects $content to be returned rather than echoed, and WP (not to mention plugins) expect $content to still be around after that function gets called. Moreover, the_title() will return garbage if you're not in the loop; this is problematic in that automatically generating an excerpt outside of the loop will call "the_content".

share|improve this answer
    
Thanks a lot! I'd normally take code I find with more of a pinch of salt, but this was linked to from the Wordpress Codex, so I thought it would have been a good example: codex.wordpress.org/…. Does that mean you have to handle the capability checking and saving of options yourself? –  Pabline Feb 7 '11 at 20:05
1  
yep. before saving use current_user_can('edit_theme_options') or whatever the cap you're restricting it to. –  Denis Feb 8 '11 at 21:02
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.