Fix for multiple roles
-
I ran into an issue when using Restrict Categories in conjuction with 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 functioncat_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 usesrtrim
on the category list. Then I added the following to functionexclusions()
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.
- The topic ‘Fix for multiple roles’ is closed to new replies.