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 used this nettuts tutorial to create an options panel. What I'm trying to figure out how to do and have been unsuccessful doing so far (I keep "breaking" the code/getting a server error) when I try to add current user info... I have 3 custom options I want available to clients while the rest are available to the admin only. I tried adding this code in my functions file but I mentioned the errors above.

if(current_user_can('manage_options')) {
array( "name" => "Site Nav Background Image",
    "type" => "section"),
array( "type" => "open"),   

array( "name" => "Site Nav Background Image",
    "desc" => "Paste URL for site navigation background image",
    "id" => $shortname."_nav_bkg",
    "type" => "text",
    "std" => ""),

array( "type" => "close"),
} else {
array( "name" => "Custom CSS",
    "type" => "section"),
array( "type" => "open"),   

array( "name" => "Custom CSS",
    "desc" => "Want to add any custom CSS code? Put in here, and the rest is taken care of. This overrides any other stylesheets. eg: a.button{color:green}",
    "id" => $shortname."_custom_css",
    "type" => "textarea",
    "std" => ""),       

array( "type" => "close"),

    }
}

I also tried creating 2 separate options functions and only one would show.

Is there an easy solution to this that I'm missing? Can someone show how I am using the above code incorrectly?

TIA!

share|improve this question

2 Answers 2

up vote 0 down vote accepted

The correct capability for editing Theme options is edit_theme_options. This capability is only available by default to users in the Administrator role.

So, if you're trying to make Theme options available for configuration by non-admins, it won't work unless you also give the appropriate capability to the user role in question.

Note: this is not a trivial change, and I do not generally recommend making Theme options configurable by non-administrators, unless you absolutely know what you're doing.

share|improve this answer
    
What I'm trying to allow them is to add a homepage facebook image, a homepage title and an area to add a table of sponsor images. The other items are theme related additions that I wanted the easy ability to add without having to delve into the theme itself. –  Justice Is Cheap Mar 13 '12 at 16:44
    
What the options are isn't really relevant. To edit Theme options, the user has to belong to the Administrator role. –  Chip Bennett Mar 13 '12 at 16:50

I could be wrong because I've always used the settings API but that tutorial looks like it's going about it the 'old way' so I'm not sure you mightn't be better of with a more up to date tutorial. Read this and check out the tutorial links at the bottom. The one I used was Chip Bennet's but that one is probably the most complex as it does tabs.

share|improve this answer
    
Thanks, I'll look this over. –  Justice Is Cheap Mar 13 '12 at 16:44

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.