Intagrat rule with flag and userpoints

Events happening in the community are now at Drupal community events on www.drupal.org.
dorijrs's picture

Hello,
I am using the Flag and User points module.
I have set a rule that when user have Flagged some content he lose 15 points.
All work just fine, but now I wold like to wright 2 rule's:
The first one is a rule that hide the flag if the user has lass then 15 points and show the flag if he has 15 or more.
The second one is that check's every 4 days if user have lass then 15 points and grand his account with 15 points.
I tested some triggers like when user has log in, but users doesn't always log out as they closing the browser.

In witch way I should do that?

Thanks.

Comments

Three ways forward

itangalo's picture

I see three ways you could go forward.

-1-
The easiest is to add 15 points every 4 days:
* Activate Rules Scheduler
* Create a rule set that gives a user 15 points, and then schedules itself in +4 days. Add a condition to check the number of points, if you like, to only add points if the user has less than 15 points.
* Create a rule that triggers on account creation, and executes the rule set above.

-2-
When it comes to hiding flags if user has less than 15 points, it becomes more tricky.
Rules is not really made to "hide" stuff, or to do any overall changes based on conditions, but rather to take certain actions when certain events occur.
You could have a rule that is activated when a node is going to be viewed, and then (maybe) hide the flag. But it would be a terrible performance hit to have this rule evaluated on each node view.

-3-
A better idea is probably to revoke a user role when the points drop below 15, and then have the flag configured so only "privileged users" can use the flag. (You'll also need a rule that gives back the privileged role when the points go back to 15.)
A problem here might be that all flags becomes invisible -- even the ones who were already set.

A fourth idea is to not do this with rules at all, but to use some other mechanism to show/hide flags. (It could probably be made quite easily in the theming layer, but then you'll only stop the flags from being displayed -- not from being used by eg hacking URLs.)

Anyway: Good luck!
//Johan Falk, NodeOne, Sweden

First thanks.

dorijrs's picture

I did what you have a in option number 1.
But it kips grand the user with 15 points without delay of 4 days, but Immediately as he press on the flag.
I did scheduled the rule set (gave the schedule right after the action grand 15 points. to "+13 day".

Thanks,
Dori

"+4 day"

dorijrs's picture

"+4 day"

Trigger on user creation

itangalo's picture

The rule described in (1) should trigger on account creation, not on using the flag.

//Johan Falk, NodeOne

What is the deference?

dorijrs's picture

?

The difference

itangalo's picture

What happens is the following:

Something happens, and the rule set is called.
The rule set gives the user 15 points, and then reschedules itself to be executed in another 4 days.
After 4 days, the rule set gives the user 15 points, and reschedules itself again. And again. And again.

The result is that once a user has created an account, he/she will get 15 points every fourth day.

However if you let the rule trigger on the flag rather than account creation, you will give the user 15 points every time he/she activates a flag (and then schedule for another 15 points in four days).

//Johan Falk, NodeOne, Sweden

It doesn't work

dorijrs's picture

As you told me I made a rule set with the following arguments:
1. Grant points to a user (15 points)
2. Schedule "AutoPoint" --> "+4 day" (with the "") --> string: Auto free points (Weight:2)
3.Triggered rules --> Event: User account has been created --> rule set: AutoPoint --> User: acting user --> Flag: active --> string: Auto free points.

I have test it with creating a new user. and the number of points after activate the account with the email link was 0...

Created user, not acting user

itangalo's picture

I admire your devotion! With this patience you will be able to learn just about any module. :-)

I see two things that might cause your rule to malfunction:

  • The ID for the scheduled rule should be unique per user, so I would recommend changing it to "Auto free points to [user:uid]" or something similar. (Install Token module if you haven't already!)
  • The user sent along as argument should be the created user, not the acting user. When people register this is usually the same, but if you as an administrator create an account you want the points to belong to the created user -- not yourself.

Good luck and don't give up!
//Johan Falk, NodeOne, Sweden

I made you a feature!

itangalo's picture

This kind of patience should be rewarded, so I made you a feature that does what you're after!
You can read about it and download it here: http://drupal.org/node/803640

You will most likely have to adjust parts of the rules to have it match your configurations, but once the feature is installed you can treat it and reconfigure it as a regular rule.

Good luck!
//Johan Falk, NodeOne, Sweden

PS: If you like Rules, answering questions or writing tutorials in this forum will help others working with Rules. :-)

Wow!!!

dorijrs's picture

Wow works just great! Many, many thanks!!!

Rules

Group organizers

Group categories

Categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: