Jump to:
| Project: | Views PHP |
| Version: | 7.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
I've been working on writing a custom php filter. Essentially, I have users tagged with a role and content tagged with taxonomy that shares a name. I want to, based on the logged in user, show relevant content based on the role. Sample code being:
<?php
global $user;
$node = node_load($data->entity);
$programs = $node->field_working_group['und'];
foreach ($programs as $program) {
$term = taxonomy_term_load($program['tid']);
if (in_array($term->name, $user->roles)) {
return FALSE;
} else {
return TRUE;
}
}
?>Nothing in my view is changing. If I dump this code into a php field within the view, I'm able to see the content in question and can do the comparisons as necessary.
I even dump return TRUE; into the filter by itself and nothing changes. Is this actually working for anyone? I've yet to find definitive documentation on how to make the filters work, and I've seen a lot of grumbling about how to make it work.
I love this module and use the custom php field extensively. I'd love to be able to incorporate the filters as well!
Comments
#1
I was just playing with this myself today. To test why my php filter code wasn't working I simply put
<?phpreturn TRUE;
?>
without the php tags of course, and all my rows were still returned. In theory, no rows should have appeared.