- πΈπ°Slovakia coaston
Hello matsbla,
I just tested path #6 it does not work for the latest version with D10 support.
I can see the option in exposed filters now and I can configure the role, but nothing happens. Still visible for everyone. - Assigned to ad0z
- Status changed to Needs work
over 1 year ago 11:36pm 22 December 2023 - π΅π±Poland ad0z
Exposed filters access handler check has to be run before view build phrase as exposed filter form is build there.
I think we can clearly run field handlers remove at that point as well, I don't see a point we could not.
I've prepared solution for that, based on my research and @matsbla work.
I've pushed working solution for me on related issue's fork, and tomorrow I will prepare browser tests as well, to make sure it is working as expected. - Issue was unassigned.
- Status changed to Needs review
over 1 year ago 3:34pm 23 December 2023 - π΅π±Poland ad0z
Added tests, GitLab CI, fixed phpcs and phpstan issues, pipeline is passing successfully on the issue fork. Review needed and some manual testing as well.
- Assigned to ad0z
- Status changed to Needs work
over 1 year ago 9:14am 24 December 2023 - π΅π±Poland ad0z
I think I found a bug, when user has no access to filter criteria - filter criteria is not applied to the view, I suppose it should not happen as view should be working as expected still. I will take a look at this.
- Issue was unassigned.
- Status changed to Needs review
over 1 year ago 10:15pm 25 December 2023 - π΅π±Poland ad0z
I thought about it more and I think it's working as expected, when user has no permission to filter whenever it's exposed or not, it should be not applied, that's make sense more We can discuss it if you think differently, but I am moving issue to needs review now.
- π¬π§United Kingdom lincoln-batsirayi
Hey @ad0z so I've got a use case for what you've described in your comment above. Essentially we've got a restricted usage field on all media items and we want to use the field to filter content if youβre a site admin on the media views. All other roles should not have access to the filter although it's default value of "Exclude" should still apply so that they don't see media items they arenβt supposed to. I was initially trying to do this through a custom form alter hook but ran into the issue youβve described even when i disabled the filter and when i installed this module i realised that it also had that very same issue...
I'm not exactly asking for this to be made as a fix on this issue as it is a niche usecase but i did wonder if you had any ideas of how it could be resolved?
- π΅π±Poland ad0z
Hi @lincoln-batsirayi,
Not sure if I got your scenario, but what if you use this module and add the filter you want twice:
- One for admin(show filter)
- One which negate admin(apply exclude option)
Then as administrator "Exclude" filter won't be applied, and you will be able to to see all options.
As non admin the "Exclude" will be applied and filter it out.There is quite few approaches to apply some custom logic for view based on roles.
I think you might use hook_views_pre_view to get rid of exposed filter/filter based on conditions.
There is hook_views_query_alter which might be helpful to alter view query based on some custom logic. - π¬π§United Kingdom lincoln-batsirayi
Thanks @ad0z the suggestion of creating 2 filters and using this module worked, thanks a lot :)