Using the Rules module to solve this challenge is indeed part of the solution. But the key part of your challenge is that you want a Rules Action to be triggered, for a Rules Event (= user performs a login) which:
- has to be repeated
- within a specified timeframe
- which don't all happen at the very same moment.
Rules is great (actually amazing), but it does not support any of the 3 bullets above. So far the bad news ...
However, your question seems like a perfect case for using the Goals module (disclosure: I'm the maintainer of it). Below is a possible configuration for it, using Goals.
Configure a goal
Navigate to the relative path admin/config/goals/manage
and use the link "Add a goal" to define just 1 goal, with a description (say):
Perform a login, 5 days consecutively
.
Configure a task
To achieve the above goal, define the Task(s) to be completed. Even though there could be multiple tasks to be completed for a single goal, in your case you just need 1. It's simply Perform a login
.
Obviously, that doesn't take into account the 5 days consecutively
-part of your question. For that you would use some of the more advanced ways to use (configure) Goals, i.e. by using these optional configuration options for this specific task:
- this task has to be repeated multiple times: in your case 5 times.
- this task requires some amount of time to expire in between any 2 similar tasks: in your case, if a user performs a login/logout multiple times a day, only the first one of every day counts.
- this task must be completed within a specific time frame (a number of times, expressed in hours, days or weeks): in your case 5 days.
Track progress while performing tasks
To track the progress made by a single user to complete this task, you only have to write an appropriate rule, using the Rules module, to record relevant events happening in your site, which are related to the completion of the task to reach the goal.
For the goal/task described above, you'd only need 1 (extremely basic) rule, which would look like so:
- Rules Event = After a user performs a login.
- Rules Action = Record a task for Goals (obviously, the task to be recorded is "Perform a login"). This is where part of the Goals magic happens, such as verifying the requirements in the optional task configuration options for a task (only once a day, etc).
Note: if the user leaves his/her browser logged in, then using this Rules Event might not be the most appropriate event. If you'd replace that event by "Drupal is Initializing" (within "System"), then such rule will be triggered for any path that the user visits. Optionally you may want to combine that Rules Event with an extra Rules Condition "User has role, with role = authenticated", so that the Rules Action(s) are only performed for logged in users.
Use Rules to process completed goals
After all tasks specific to a goal are completed by a user, the goal is automagically marked as completed. But, that's where it gets really interesting: you can also create additional rules that will be triggered (Rules Event) when a goal is completed by a user. With that, the answer to your question is extremely easy: perform a Rules Action to "... grant userpoints to the user who completed the goal" ... which is exactly what your question is about, no?
More info
Refer to my answer to "How to implement gamification in a Drupal site and award incentives?" for additional details about the Goals module.
Note: Using Goals only requires typical administration tasks (configuration), though it does come with various hooks also for custom module development (if you want to).