I am using Rules Scheduler and Flag to handle troublesome users by issuing a one-week ban. I flag the user with a temporary ban flag, and then the user sees a special block that says "You have been temporarily banned for being a jerk." I have a rule that automatically schedules the user to be unflagged one week later.
However, I want to show users how much time they have remaining. My first thought was to create a block/content pane in Views, so I made a view of type Rules scheduler, but when I went to add the UID as a Contextual Filter, I realized that Rules scheduler views only provide these options:
- Null
- Component name
Is there some other way I can show the user how much time they have until an arbitrary Rules Scheduler action will be evaluated?
What I tried
Based on this question, I added a filter for user-provided identifier, set the value to a garbage value (punishme), and added views_pre_view()
as follows:
function MYMODULE_views_pre_view(&$view) {
global $user;
if ($view->name == 'punishment_show_details') {
if ($user->uid) {
$newvalue = 'punish/' . $user->uid;
$view->display[$view->current_display]->handler->options['filters']['rules_scheduler']['value'] = 'punish/' . $user->uid;
}
}
}
However, this doesn't work; for some reason, when I dpm()
the view, the value for filters
is empty.