1

Screenshot below says it all. I want to remove/hide this field from view so the user is unable to edit it. It comes from the User Role Editor plugin and I want to make the changes in functions.php in the child theme.

As far as I can tell the code that creates the option comes from plugin folder in ./includes/classes/user-other-roles.php.

I've tried taking the whole function and dropping it into the child theme functions.php and commenting out the 'select_roles' line but that didn't work.

public function load_js($hook_suffix)  {

    if (!in_array($hook_suffix, array('user-edit.php', 'user-new.php'))) {
        return;
    }


    $select_primary_role = apply_filters('ure_users_select_primary_role', true);

    wp_enqueue_script('jquery-ui-dialog', '', array('jquery-ui-core', 'jquery-ui-button', 'jquery'));
    wp_register_script('ure-jquery-multiple-select', plugins_url('/js/jquery.multiple.select.js', URE_PLUGIN_FULL_PATH));
    wp_enqueue_script('ure-jquery-multiple-select');
    wp_register_script('ure-user-profile-other-roles', plugins_url('/js/user-profile-other-roles.js', URE_PLUGIN_FULL_PATH));
    wp_enqueue_script('ure-user-profile-other-roles');
    wp_localize_script('ure-user-profile-other-roles', 'ure_data_user_profile_other_roles', array(
        'wp_nonce' => wp_create_nonce('user-role-editor'),
        'other_roles' => esc_html__('Other Roles', 'user-role-editor'),
        'select_roles' => esc_html__('Select additional roles for this user', 'user-role-editor'),
        'select_primary_role' => ($select_primary_role || $this->lib->is_super_admin()) ? 1: 0
    ));
}

User Role Editor

3
  • I'd advise you to ask the plugin author on their support page. You may not get an answer here because someone would have to be familiar with that plugin. You could also increase your likelihood of getting an answer if you post some code showing effort. Nov 8, 2017 at 23:40
  • Figured it out and posted the solution below.
    – Jason
    Nov 20, 2017 at 3:53
  • 1
    Thank you for asking this question. I didn't realize URE was where the "other roles" dropdown was coming from - we were using Multiple Roles plugin and so we had multiple ways to add multiple roles. Finding out what was adding it and how to remove it was really helpful!
    – WebElaine
    Dec 6, 2018 at 22:56

3 Answers 3

1

Add this line to your functions.php file:

add_filter( 'ure_show_additional_capabilities_section', '__return_false' );

You're welcome :))

1

I figured it out and this may help others who may also be trying to remove options from within the dashboard. The concept is the same for any other item you may wish to remove. First you need to add a filter to your functions.php in your child theme. Then you set the function to false.

Here is the code:

// remove additional capabilities dropdown from user page
add_filter('ure_show_additional_capabilities_section', 'ure_show_additional_capabilities_section');
add_filter('ure_bulk_grant_roles', 'ure_show_additional_capabilities_section');

function ure_show_additional_capabilities_section($show) {
  if (current_user_can('administrator'))     {
    $show = false;
  }

  return $show;
}
0

Your code causes a fatal error when activated, seems it has an extra ) on line 6.

    // remove additional capabilities dropdown from user page
    add_filter('ure_show_additional_capabilities_section', 
    'ure_show_additional_capabilities_section');
    add_filter('ure_bulk_grant_roles', 
    'ure_show_additional_capabilities_section');

    function ure_show_additional_capabilities_section($show) {
      if (current_user_can('administrator'))     {
        $show = false;
      }

      return $show;
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.