Title: Differences between plugin and add_cap() function
Last modified: December 5, 2022

---

# Differences between plugin and add_cap() function

 *  Resolved [arg0n](https://wordpress.org/support/users/arg0n/)
 * (@arg0n)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/differences-between-plugin-and-add_cap-function/)
 * Helo
 * I don’t understand one thing. I would like the user to have access to the list
   of users (without administrators).
 * When I do something like this:
    add_role( ‘testrole’, ‘testrole’);
 * $test_role = get_role(‘testrole’);
    $test_role->add_cap(‘list_users’);
 * the user also sees administrators in the user list.
 * When I add a role using the User Role Editor plugin and add list_users cap, the
   user has access to the list of regular users only.
 * What is the difference between these two situations?
 * _Additionally, if I add a role via code, all I have to do is enable the plugin
   so that only regular users appear in the list (without admins)._

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Vladimir Garagulya](https://wordpress.org/support/users/shinephp/)
 * (@shinephp)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/differences-between-plugin-and-add_cap-function/#post-16264235)
 * Hi,
 * URE plugin includes a piece of code to hide users with ‘administrator’ role from
   any other user who can ‘edit_users’ capability. When you activate URE, this code
   works by default.
 *  Thread Starter [arg0n](https://wordpress.org/support/users/arg0n/)
 * (@arg0n)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/differences-between-plugin-and-add_cap-function/#post-16264667)
 * Thank you for the information,
 * I found this snippet in protect-admin.php
 * (This also works with only list_users cap, without edit_users)
 * problem solved
    -  This reply was modified 3 years, 5 months ago by [arg0n](https://wordpress.org/support/users/arg0n/).
    -  This reply was modified 3 years, 5 months ago by [arg0n](https://wordpress.org/support/users/arg0n/).

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Differences between plugin and add_cap() function’ is closed to new replies.

 * ![](https://ps.w.org/user-role-editor/assets/icon-256x256.jpg?rev=1020390)
 * [User Role Editor](https://wordpress.org/plugins/user-role-editor/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/user-role-editor/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/user-role-editor/)
 * [Active Topics](https://wordpress.org/support/plugin/user-role-editor/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/user-role-editor/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/user-role-editor/reviews/)

## Tags

 * [admin](https://wordpress.org/support/topic-tag/admin/)
 * [administrators](https://wordpress.org/support/topic-tag/administrators/)
 * [only](https://wordpress.org/support/topic-tag/only/)
 * [role](https://wordpress.org/support/topic-tag/role/)

 * 2 replies
 * 2 participants
 * Last reply from: [arg0n](https://wordpress.org/support/users/arg0n/)
 * Last activity: [3 years, 5 months ago](https://wordpress.org/support/topic/differences-between-plugin-and-add_cap-function/#post-16264667)
 * Status: resolved