Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
in Plugins by
Is it available, to offer users points for everyday visit on site (1 for 24 hours) ?
Maybe anyone knows how to do this ? :)
I think it's not hard to do :)

Q2A version: 1.7.4

1 Answer

+2 votes

It is not "available" but it is feasible, as most things. Q2A does not allow an easy way (a module) to hook on point recalculation for users. That means when it comes to calculating points things can get a bit messy. There are also some issues to take into account such as re-calculating points, e.g., what impact will that have (it can even remove all the non-core points and users won't be happy).

Leaving aside more "appropriate" and too-long-to-explain implementation approaches, I'm adding a list of the steps to implement this plugin in a quick and dirty way. The idea would be to use the bonus points. That can be set manually by the admin but instead of doing that we can switch that feature into something that would allow us to track those points.

  1. Create a table to track user progress with the following structure (user_id, last_visit, days), being user_id an FK to the users table (assuming you're not using external users, of course)
  2. In a layer (or process module) check on every page refresh (you could decrease this frequency with a cookie or something) that table:
    1. If the user is not in the table then add it setting last_visit to today and days to 1
    2. If the user is in the table and last_visit < today then increment the value days
    3. If the user is in the table and last_visit = today then take no action
    4. If the user is in the table and last_visit > today then beware, he comes from the future: hide any flux capacitors you have at home
  3. Still when performing that refresh update the bonus for the user setting it to days * day_point_multiplier
  4. You could even rename the bonus points to "Daily points" or something
Pretty simple but this will tie your bonus points to that daily points. That is why it is quick and dirty enough to be added as an answer :)
thanks a lot ! I will check how it's possible, but I'm not sure, can I do this, but I'll try ;)
BTW If anybody's interested to make plugin like this, would be great ;-)