Selectively Disable Theme inserted Menu Items

Hello,

I have a client website using a particular theme. That theme has some features I will not be using for instance 'Testimonials'

There is no 'theme supplied' method of removing that admin link from view. Is there a work around or plugin that would allow me to control my clients being able to view such a dead unusable link from their view ?

If need be, I'll consider a manual php or js solution that says if url='asdfasdf.com' hide menuItem-33 or whatever. See attached for example of menu items I wish to hide.

What sayeth the group ?

Jay

  • Tyler Postle

    Hey Jay,

    Hope you're day is going well so far!

    As for your question, I think I may have the perfect plugin for you: https://wordpress.org/plugins/admin-menu-editor/

    With that plugin you can remove any un-needed menu items :slight_smile:

    Another useful plugin is the User Role Editor. If you ever need to revoke the capability for a user to do something, instead of just hide it, then it can come in very handy: http://wordpress.org/plugins/user-role-editor/

    Hope that helps! Let us know if you need any further assistance.

    All the best,
    Tyler

  • Jay

    Thanks Tyler,

    Regrettably, neither one of those works in the way I needed it to which is to qualify it based on whether it was a Super Admin but also a lot of detailed things I wanted to hide which were also not addressed. In addition I may need a domain based filter as well which is not touched in either of those.

    So I wrote a bit of code for now and handled it manually. Here it is for the rest of the group so they may benefit or improve it:

    In any theme's functions.php place the following which will qualify if a super admin and we are in the admin log in section and call a javascript scripts page if it meets that criteria.

    function my_script() {
    # you could further qualify this based on the domain being entered...
    if(get_site_url()=='http://yourdomain.com'){
    // for possible future use
    }
    # Jay if it is not a super_admin and we are logged in to admin area
    # this will run the javascript code to disable unneeded menu selections.
    if(is_admin() && !is_super_admin()){
    wp_enqueue_script( 'my_custom_script',get_stylesheet_directory_uri() . '/cm_admin_scripts.js', array('jquery'));
    }
    }
    add_action('admin_enqueue_scripts', 'my_script');

    That done, here's the jquery code to disable all sorts of links and buttons in the admin section I don't want my client to see.

    jQuery(document).ready(function(){
    jQuery('#menu-posts-dict_camera_slider').css('display','none');
    jQuery('#menu-posts-dict_service').css('display','none');
    jQuery('#menu-posts-dict_parallax_slider').css('display','none');
    jQuery('#menu-posts-dict_slicebox').css('display','none');
    jQuery('#menu-posts-dict_partner').css('display','none');
    jQuery('#menu-posts-dict_testimonial').css('display','none');
    jQuery('#menu-posts-dict_portfolio').css('display','none');
    jQuery('#menu-posts-dict_history').css('display','none');
    jQuery('#menu-comments').css('display','none');
    jQuery('#menu-posts-product').css('display','none');
    jQuery('#toplevel_page_sh_theme_options').css('display','none');
    jQuery('#menu-appearance').css('display','none');
    jQuery('#menu-plugins').css('display','none');
    jQuery('#menu-tools').css('display','none');
    jQuery('#menu-settings').css('display','none');
    jQuery('#toplevel_page_sh_timetable').css('display','none');
    jQuery('#collapse-menu').css('display','none');
    jQuery('#menu-posts').css('display','none');
    jQuery('#toplevel_page_psts-checkout').css('display','none');
    jQuery('#menu-dashboard').css('display','none');
    jQuery('#wp-admin-bar-updates').css('display','none');
    jQuery('#wp-admin-bar-comments').css('display','none');
    jQuery('#wp-admin-bar-new-content').css('display','none');
    jQuery('#wp-admin-bar-psts-status').css('display','none');
    jQuery('#wp-admin-bar-pro-site').css('display','none');
    jQuery('#wp-admin-bar-psts-status').css('display','none');
    jQuery('#wp-admin-bar-psts-status').css('display','none');

    });

    Jay

  • aristath

    Hello again @Jay, I hope you're well today!

    Nice going there... I'm glad you managed to figure this one out, and thank you for posting your solution in the forums. I'm sure other members will find that useful as well... so I just sent some rep point your way. :slight_smile:

    I'm marking this issue as resolved. If however you need any further assistance with this, then don't hesitate to reopen this and post an update on your current status.

    Take care,
    Ari.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.