0

I have a Drupal website which uses webforms and a custom module to manage the access in their submissions using hook_webform_submission_access.

While successfully restricting the access of a webform submission to a user, though, when they view the "Results" tab (or the "Table) the access filter isn't triggered as these tables are generated by Views.

How can I add a filter to the default "Webform submissions" view in order not to show the ones that the user has no access on?

PS: I know I can use hook_views_pre_render and unset the rows from the results, but I believe a filter would be a better and more elegant solution.

  • what condition you wants to use for filter? – DRUPWAY Nov 18 '16 at 19:10
  • Do you wants to set user can see his own submission? – DRUPWAY Nov 18 '16 at 19:10
  • No, it's custom code using hook_webform_submission_access, it checks some user data with the submission data and returns TRUE/FALSE. Potentially I could replicate the logic but I'd like to ask the view to check whether the user has general access to the submission. – Thomas Pappas Nov 18 '16 at 19:30
0

You can use Views PHP module.

This module allows the admin account (user 1) to add fields, filters and sorts to views which use PHP code. It also supports additional accounts when the core PHP Filter module is enabled.

Enable this module and add a filter PHP filter which you can select from views filter Global Category once you install above module.

Add php code for filter condition as per your requirement.

|improve this answer|||||
  • Thanks for the answer, this solution is indeed working but I've been looking for a way to do it without this module by using custom handlers. – Thomas Pappas Jan 5 '17 at 11:25

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.