0

I've created a Like flag using flag module and a page view to list all people who like the currently logged in user. The views works good and am getting a list of users who like me (the currently logged in user). I want to filter the list of people who've liked me since my last login.

Been messing with the user:last login and user:last access filters. Can't find to make it work. Can anyone please help me with this?? (edit: I realize that the user:last login and user:last access filters is for filtering the list of users so no luck yet)

  • 1
    Hello. Please add a bit of information to your post: 1) What module are you using to flag / like users? 2) provide implementation you have tried (either descriptively, or by the screenshot, or by pasting relevant part of exported view as code) and the results you got. – Mołot Nov 22 '13 at 8:27
  • Hey Molot, thanks for the reply 1. am using flag module 2. The list of people who flag/like me is working good. My issue is,I need a list of users who liked/flagged me since i last logged in. I realized that the last login and last access filters in views is to filter the user list according to their last login/access. Not possible with views i guess. – jack Nov 22 '13 at 23:45
  • Please edit important parts into your question :) – Mołot Nov 22 '13 at 23:49
2

In the filter criteria add flaggeds time filter. An operator with is greater than or equal to and write a date whatever you want, doesnt matter wich one, because where are going to modify programmatically later.

Then in your module we have to rewrite that filter to put the last login from the user.

/**
 * Implements hook_views_pre_view.
 */
function YOUR_MODULE_views_pre_view(&$view) {
  if ($view->name == 'VIEW_NAME') {
    global $user; //Load user
    $view_filters = $view->display_handler->get_option('filters');
    // Put the user last login in the flag filter we created before
    $view_filters['timestamp']['value']['value'] = date('Y-m-d H:i:s', $user->login);
    $view->display_handler->override_option('filters', $view_filters);
  }
}
|improve this answer|||||

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.