[Resolved] Allow editor to manage content of a specific sidebar text widget
It’s frustrating that I cannot assign ownership of a sidebar text widget to enable a client to modify its content without enabling that client to have full admin privileges.
I have looked, unsuccessfully for a widget permissions plugin, similar to widget-logic.
An alternative solution would be a widget that would display the contents of a draft post based on it’s ID#. That post wouldn’t appear as a blog but it could contain the updatable contents (i.e. weekly schedule) that we want to appear on every page of the site. The person who “owns” that post could thereby effectively change the content of the sidebar.
A more accurate title for this post would be “Allow non-admin to manage content of a specific sidebar text widget”.
I’m attempting to write you something to do this, it’s rather simple, i’ve just not registered a widget before, so just working out how to use the widget api.
Here’s how i plan for it to work.
The plugin will provide a basic option page, on this page an administrator will need to provide a user’s ID, and save the value (setting is registered, just enter a value and hit save).
Once that’s done a new widget will be available to you, or anyone able to manage widgets, however, the input fields will not be editable or changable by any user except the user with the ID set by the admin earlier. Any other users will see a generic message, “You are not able to edit this widget”, or something to that degree (havn’t got to that part yet).
Or at least that’s the plan.. watch this space..
I’ve just realised something.
No role below the admin level can edit theme options, and for that matter widgets.
EDIT: This might not work out, see the suggestion further down.
Maybe if you could tell me which role the user in question has i write some addition code to add a new role that matches the current role, but also assigns the
edit_theme_optionscapability, which will be required to edit widgets.
This would mean the user gets access to theme options, if that’s not a problem, great, easy fix. If not, what i can suggest is using a few more lines of code to hide the addition menu items that the user will now see (hide them so the user doesn’t know he can do other things). Additionally, if we do need to hide menu items i believe i can also intercept the page requests to theme option pages, “Appearance”, “Editor”, etc.. and chuck up an error message if he/she tries to request those pages (so essentially stopping the user being able to do anything other than manage widgets).
However i’ve not considered that you may not want this user to edit “other” widgets, which might make things much more tricky.
—— New suggestion ——
On second thought, i could do what you suggested in your opening post, and rewrite the widget to pull data from a draft post, and leave the admin settings with the admin, ie. make it so you can update and change which draft post it pulls data from.
I’d need to know a few specifics about the Draft post you want to pull into the widget, but i can see this being a far easier approach then making a widget that works for one user (this would be the favourable option, and most likely to work – having thought about the capability problem).
Let me know how you feel about the above and we’ll go from there.. 😉
Pulling from a draft would be fine.
In theory, it would be possible to have 3 instances of such a widget and specify 3 different draft post #’s in the admin panel.
Whoever has edit rights on that post would effectively change the content of what appears.
This would be a VERY cool thing.
I just posted basically this same question, and then answered it myself.
If you can edit in PHP, you can potentially modify the sidebar PHP so it displays its own widget-like content that displays a specific post. I set it up to look for a post with a specific Tag. Then you instruct your non-admin users to edit that post to change the content.
Yes, different instances will be able to each pull from different drafts… 🙂
Was going to reply sooner but wanted to add a few options and test the widgets (seems to be good now).
Give this a try.
Can be used as a plugin, or alternately remove the comments at the top and place in the theme functions file (taking care with the PHP tags – placement is important).
This absolutely ROCKS!
You can see it in action on http://www.anshe.org/ in the right margin in the This Week section.
This plugin will allow me to delegate the weekly update of this section to someone else without having to concern them or me with their having admin privileges.
THANK YOU THANK YOU THANK YOU!
You’re welcome.. 🙂
Let me know if anything requires adjustment, i wrote it not fully knowing what your exact usage would be, so if you’d like something added/changed, just post back.. 🙂
How about makeing this, not bound to a draft but to a private post.
As it is now, as a draft, you have to click Save Draft, and not the update/publish button that we are used to click.
If a client, or user with no skills do this out of old habbits, he will disable the widget draft.
hello I’m new to WP, not good with the file structure. Aaron’s text widget editing solution is what I’m looking for too.
I copied Mark’s code and made a user_drafts_widget.php, ftp to plugin folder, activated the plugin. Then I look through dashboard, posts, text widgets, users… area but cannot see anything relevant. Could someone point me to the right direction? Thank you so much!!
I know this thread is a bit dated, but I had this same issue and wanted to share my solution.
I used the ‘Capability Manager‘ plugin.
Once activated change the settings on the ‘Capabilities’ page under the ‘Users’ menu.
Select the ‘Editor’ role to edit and tick ‘Edit theme options’ before saving.
The ‘Editor’ user type now can add/edit ‘Widgets’ and ‘Menus’ under the ‘Appearance’ menu.
They can also view the current theme, but cannot change or edit it.
Hope this helps!
- The topic ‘[Resolved] Allow editor to manage content of a specific sidebar text widget’ is closed to new replies.