WordPress.org

Forums

Limit what certain roles see on profile / admin page (6 posts)

  1. Vezado
    Member
    Posted 3 years ago #

    I'm starting a private WP site using the 'Members' plugin. All students are 'subscribers' with only the ability to read posts.

    Ideally, i'd like to admin pages to only show the basic profile info (name / contact / about). If they go to the admin page, they are currently able to see a few things that I wish they didn't:

    • "Security Points' rating for Ultimate Security checker (but don't have sufficient permissions to make changes of course
    • WordPress button and support links. Not needed for them
    • They can access the dashboard, also not needed, it's just wordpress news.
    • I've got qtranslate and they can see a link for each different language. but links are dead because of their role.

    What is the best way to selectively remove items from the admin panel?

  2. keesiemeijer
    moderator
    Posted 3 years ago #

    For the WordPress button and support links, and the Ultimate Security checker you can put this in your theme's functions.php :

    add_action( 'admin_bar_menu', 'remove_toolbar_items_for_subscribers', 999 );
    function remove_toolbar_items_for_subscribers( $wp_admin_bar ) {
      if(current_user_can('subscriber')) {
        $wp_admin_bar->remove_node('theme_options');
        $wp_admin_bar->remove_node('wp-logo');
      }
    }

    Try a plugin for the dashboard: https://wordpress.org/extend/plugins/wp-hide-dashboard/

  3. keesiemeijer
    moderator
    Posted 3 years ago #

    Try it with this in your functions.php for qtranslate:

    if(is_admin()){
        add_action('admin_menu', 'remove_q_links');
      }
      function remove_q_links(){
        global $q_config, $pagenow;
        if(current_user_can('subscriber')) {
          if(sizeof($q_config['enabled_languages']) <= 1) return;
          foreach($q_config['enabled_languages'] as $id => $language) {
            $menu_slug = $pagenow.'?lang='.$language;
            remove_menu_page( $menu_slug );
          }
        }
      }
  4. Vezado
    Member
    Posted 3 years ago #

    Thanks for your help.

    I was able to remove the admin bar entirely for subscribers using the plugin 'Adminimizer' and I found that qtranslate has an option to remove the buttons:

    http://wordpress.org/support/topic/plugin-qtranslate-remove-flags-in-admin-menu?replies=2

    I'll add a modified version of your first script for myself, that's useful.

  5. keesiemeijer
    moderator
    Posted 3 years ago #

    I found that qtranslate has an option to remove the buttons

    Hacking the plugin is of course also a way to do it. But then you have to add the line of code every time you update the plugin.

    Glad you got it resolved.

  6. Vezado
    Member
    Posted 3 years ago #

    Hacking the plugin is of course also a way to do it. But then you have to add the line of code every time you update the plugin.

    Good point, i had thought of that. The developer needs to move that config option into the admin settings, editing a php file is lousy way to set options.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.