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:
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
Comment #1
rbruhn commentedI was just playing with this myself today. To test why my php filter code wasn't working I simply put
without the php tags of course, and all my rows were still returned. In theory, no rows should have appeared.
Comment #1.0
rbruhn commentedAdded a note.