Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently, the 'submit result' link always appears on the 'pending results' view. There should either be a privilege check on the custom field (if possible), or there should be two views ... add one without the 'submit result' action link, and have the page code choose between the two views.
Comments
Comment #1
jthorson CreditAttribution: jthorson commentedAdded hook_views_post_render function to ult_modules, which does an _ult_matches_modifygame_access call for each game/row in the view and strips out the 'Submit Result' custom text from that row if the access check does not pass.
It does this by stripping the link out of the view's $output variable, which I'm not completely happy with ... but since custom text values haven't been added to the view yet in hook_views_pre_render; and the value can't be changed in hook_views_post_render; the only other alternative is to put the access check into a theme function or template for that field (as suggested by merlinofchaos in #837686-3: Injecting a new field before rendering OR changing the value of a field (placeholder one) before rendering ).
To me, this approach breaks the separation of logic from presentation rules, so I went with the string substitution in the $output string - but my personal belief is that Views should populate custom text values before hook_views_pre_render is called, and the removal of the 'submit result' string could then happen there.