• I have a WordPress website and I have custom User Role called “AdsUsers” this created for users that have permissions to manage the Ads Widgets that located on the sidebar, but as you know the WordPress sidebar has other types of weights too, besides the Ads Widgets. How we can prevent the users that have “AdsUsers” user role to change other widgets settings? because this role created to manage Ads Widgets only.

    • This topic was modified 5 years, 2 months ago by mohammaddiab.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    It’s normally an all or none situation. A user can either edit all widgets, or none. I recommend the following to get around this: Figure out how and where the Ads widget saves its options.

    Take away the “edit_theme_options” capability from the AdsUsers role. They will be shut out from the widgets page. Then assign a custom capability for editing just the Ads widget options. Assign this capability to admins and other roles who should be able to edit options as well.

    Add a new admin page that is accessed by those with the custom capability that contains the Ads widget options and updates entered data in the proper places for that widget.

    Thread Starter mohammaddiab

    (@mohammaddiab)

    @bcworkz Thank You very much for your quick reply, that great idea, but how I can create admin page and access to Ads widget options, there is any code example or helpful links?

    Moderator bcworkz

    (@bcworkz)

    For adding admin pages in general, see Administration Menus in the Codex. For the Ads widget options, you could try examining the widget’s source code for clues. If you can find the related settings in the DB through phpMyAdmin, it would be enlightening. It generally would be in options table under the key “widget_{$widget_name}”. Settings are normally saved as a serialized array. You could try asking the developers of the plugin for advice.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to Customize Widgets based on User Role?’ is closed to new replies.