1

I used this link to set up a UserPoints Store:

Drupal 7 - How to Set up a Simple UserPoints Store.

I need help finishing one thing:

  • When user flags item
  • some code starts working and logs the fact that this specific user just flagged this specific page(content)
  • Once this information is logged somewhere.
  • the page(content) that the user see's as [Already Flagged] needs to automatically unflag.
  • So that user can flag it again if he/she wishes.

If you look in the link above it can be understood that flagging a item(page/content) deducts points from the UserPoints system. As soon as the user presses flag this they get the option to type in the quantity they would like to "purchase" or flag. I need this quantity logged too.

In short, this is an example of how it should log:

User | Time/Date | Quantity |  Page    
-----+-----------+----------+--------
id2  | 8/18/2016 |     3    | /node/9
id7  | 2/13/2016 |     1    | /node/5
id4  | 4/28/2016 |     1    | /node/1

I hope it makes sense. It would make more sense if you take a look at the info in the link.

  • You want it to unflag without a page reload? – Niall Murphy Aug 19 '16 at 16:04
  • Ok, I think I'm getting to understand the question... The log is separate to the unflagging stuff and is just for your own records? There's a log automatically created and you can create a "userpoints transactions" view to display it. Adding an answer now. – Niall Murphy Aug 20 '16 at 3:16
1

The Log

Userpoints transactions are automatically "logged" in that Views can display them with all required data. So if I understand the question correctly, flags is irrelevant here in terms of logging as you just want the userpoints transactions.

Create a "userpoints transactions" view.. Not "content" or "user".

  1. Add a relationship for Userpoints Transactions: User
  2. Add fields for
    (Users) User: Uid (Uid),
    Userpoints Transactions: Timestamp (Timestamp),
    Userpoints Transactions: Points (Points) and
    Userpoints Transactions: Entity ID (Entity ID) (according to your link, this should be the node id)
  3. If you have more than one category of userpoints, you can add a filter for Userpoints Transactions: Category

Automatic Unflag

It sounds like in your link, Business Rule 2: Unflag an item is unneeded in your case? I'd just change this to a rule where the the flag is unflagged and then redirect to the node / page if needed. I'm not really sure what the requirements are here.

| improve this answer | |
  • It seems like I don't have user(uid) as one of the field options for some reason... – Sammy7 Aug 20 '16 at 3:57
  • I just realized what you meant by Business Rule 2 is not needed great idea. And through rules I could add an action to unflag. Then the points are taken but never given back! And it records it which is Great! Thanks – Sammy7 Aug 20 '16 at 4:02
  • I know in (admin > Configuration > UserPoints > Transactions) I can see all the transactions, but it would be easier if it could show me the page on which the transaction happened and be able to sort only flagging transactions. That is what you described above but when I go to add view it doesn't let me sort UserPoints by user. Do you know why? – Sammy7 Aug 20 '16 at 4:03
  • After you add the relationship, you still don't have user: uid as a field? I completely forgot about that admin page.. I'm so used to creating admin stuff for end-users. So do you need any more help or is it ok now? – Niall Murphy Aug 20 '16 at 4:12
  • well I would rather create a view like you said if possible. But what do you mean add the relationship... Where in views? – Sammy7 Aug 20 '16 at 4:14

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.