WordPress.org

Forums

Dynamic Widgets
[resolved] Remove Dynamic Widgets from Appearance menu (11 posts)

  1. WebEndev
    Member
    Posted 4 years ago #

    I was wondering if there was a way to remove the admin link for Dynamic Widgets in the Appearance admin menu?

    I am enabling the Appearance menu for the editor role, and would like to remove the Dynamic Widgets submenu item.

    I've tried various times with remove_submenu_page, but have had no luck.

    Wouldn't it be better to put the admin link under Settings instead of Appearance? This is where most plugin admin is put.

    Thanks!

    http://wordpress.org/extend/plugins/dynamic-widgets/

  2. Qurl
    Member
    Plugin Author

    Posted 4 years ago #

    Please correct me if I'm wrong, but I don't think an editor has "edit_theme_options" capabilities, so the menu item won't be at least accessible.

  3. WebEndev
    Member
    Posted 4 years ago #

    Please correct me if I'm wrong, but I don't think an editor has "edit_theme_options" capabilities, so the menu item won't be at least accessible.

    That is correct. Let me clarify.

    What I did was add

    $role = get_role('editor');
    $role->add_cap('edit_theme_options');

    to allow the editor role to see the Appearance menu (because I wanted them to be able to access Widgets, and Menus).

    I then added

    function we_custom_admin_menu() {
        $user = new WP_User(get_current_user_id());
        if (!empty( $user->roles) && is_array($user->roles)) {
            foreach ($user->roles as $role)
                $role = $role;
        }
    
        if($role == "editor") {
           remove_submenu_page( 'themes.php', 'themes.php' );
        }
    }
    add_action('admin_menu', 'we_custom_admin_menu');

    To remove the Themes submenu item.
    But the Dynamic Widgets submenu item is still there in the Appearance menu, because it is called with themes.php

    But I don't want the Editor role to see the Dynamic Widgets submenu.

    So... how do I remove it?

    Thanks!

  4. Qurl
    Member
    Plugin Author

    Posted 4 years ago #

    Try
    remove_submenu_page( 'themes.php', 'dynwid-config' );

    Please be aware there is also a DW link within the Widgets Admin.

  5. WebEndev
    Member
    Posted 4 years ago #

    Yeah, I already tried that. Didn't work. Sorry...

  6. Qurl
    Member
    Plugin Author

    Posted 4 years ago #

    Did you also try
    remove_submenu_page( 'themes.php', 'themes.php?page=dynwid-config');

  7. WebEndev
    Member
    Posted 4 years ago #

    Just tried
    remove_submenu_page( 'themes.php', 'themes.php?page=dynwid-config');
    That didn't work either.
    I found another way to hide it as a work around.

    So I can get by...
    Thanks

  8. feshin
    Member
    Posted 3 years ago #

    HI WebEndev --

    Do you mind sharing your solution to hiding the dynamic widgets from the appearance menu? I'd love to do the same thing.

    Thanks!

  9. WebEndev
    Member
    Posted 3 years ago #

    Hi Feshin,

    I looked around, but couldn't find my coded solution.

    This however http://wordpress.org/extend/plugins/admin-menu-editor/ works very well and will to it for you.

  10. feshin
    Member
    Posted 3 years ago #

    Thanks, WebEndev! I'll take a look at that plugin. Really appreciate you taking the time to respond!

  11. Qurl
    Member
    Plugin Author

    Posted 3 years ago #

    Thanks for sharing WebEndev!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Dynamic Widgets
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic