Title: Fix for multiple roles
Last modified: August 30, 2016

---

# Fix for multiple roles

 *  [mikecwc](https://wordpress.org/support/users/mikecwc/)
 * (@mikecwc)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/fix-for-multiple-roles/)
 * I ran into an issue when using Restrict Categories in conjuction with [Multiple Roles](https://wordpress.org/plugins/multiple-roles/).
   Categories were restricted as expected for users with only a single role assigned,
   but users with multiple roles would have two categories missing from the Category
   management page, Posts dropdown, and the category list on the New/Edit Post page.
 * I tracked it down to an issue with the way category IDs were being added to `
   $this->cat_list`. The function `cat_filters()` is applied to `$this->cat_list`
   after adding all the categories for one role to cat_list. This function trims
   the trailing comma from the end of the list. When combined with multiple roles,
   this results in two category IDs being joined into a single (invalid) one.
 * So if Role A can post to categories 10 and 11, and Role B can post to categories
   12 and 13, the resulting cat_list for a user with both roles would end up being:
 * `10,1112,13`
    instead of `10,11,12,13`
 * I fixed this by commenting out line 518 in the `cat_filters()` function – the
   one that uses `rtrim` on the category list. Then I added the following to function`
   exclusions()` on line 569:
 * `$this->cat_list = rtrim($this->cat_list, ",");`
 * This way it doesn’t trim off the trailing comma until the last possible moment
   before adding it to the SQL query.
 * That seemed to clear it up for me. I haven’t found any other issues that might
   be caused by this rearrangement.
 * [https://wordpress.org/plugins/restrict-categories/](https://wordpress.org/plugins/restrict-categories/)

Viewing 1 replies (of 1 total)

 *  [karidemi](https://wordpress.org/support/users/karidemi/)
 * (@karidemi)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/fix-for-multiple-roles/#post-6350579)
 * I ran into a similar issue while using WPFront User Role Editor. The role editor
   allows you to assign multiple secondary roles to a user. Assigning multiple roles
   that are restricted by category results in the user seeing nothing, when really,
   they should see any items in category A OR category B.
 * The above fix corrected the problem. Is there anyway it could be added to the
   plugin directly? I too have not found any issues since I made the modification.

Viewing 1 replies (of 1 total)

The topic ‘Fix for multiple roles’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/restrict-categories.svg)
 * [Restrict Categories](https://wordpress.org/plugins/restrict-categories/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/restrict-categories/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/restrict-categories/)
 * [Active Topics](https://wordpress.org/support/plugin/restrict-categories/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/restrict-categories/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/restrict-categories/reviews/)

## Tags

 * [conflicts](https://wordpress.org/support/topic-tag/conflicts/)

 * 1 reply
 * 2 participants
 * Last reply from: [karidemi](https://wordpress.org/support/users/karidemi/)
 * Last activity: [10 years, 9 months ago](https://wordpress.org/support/topic/fix-for-multiple-roles/#post-6350579)
 * Status: not resolved