how can i deduct users(member) points by user's last login..?
the workflow maybe like this :
user A had 100 points, if user A didn't log back in 2 days, his/her points will be deduct 10 points automatically...

Can anyone help me to achieve this.

Comments

adit234’s picture

Component: Code: userpoints_rules/userpoints_workflow_ng » Code: userpoints API

still waiting....:(

berdir’s picture

Priority: Major » Normal

When is this supposed to happen? When he logs in again? Or regularly (eg. loose 10 points for every 2 days you aren't logged in)

You need custom code for both of these.

The first is simpler. Implement hook_user() op login. Check last login time, subtract points for the difference with userpoints_userpointsapi(). But this means that points are only subtracted if he logs in again.

The other way would be to implement hook_cron(), check for users which haven't logged in in the last 2 days and have points and haven't already been deducted points in the last two days (custom table). Then remove some points for them, add them to your custom table (uid and timestamp).

Note that this is not a support forum. Feel free to ask specific, userpoints.module related questions and I'll try to help but I won't give you code that you can just copy and paste.

berdir’s picture

Status: Active » Postponed (maintainer needs more info)
adit234’s picture

thanks @Berdir for quick response

The first is simpler. Implement hook_user() op login. Check last login time, subtract points for the difference with userpoints_userpointsapi(). But this means that points are only subtracted if he logs in again.

this is what i want.

actually i'm lack of experience in PHP plus i'm still newbie in Drupal. I think, i will go to support forum to create (if i can) my own code...:D

thanks anyway @Berdir and sorry for my bad english....;)

berdir’s picture

Status: Postponed (maintainer needs more info) » Fixed

The userpoints specific part of that is very simply. You just need to call "userpoints_userpointsapi($points)", where points could e.g. be -5. You need to figure out when to do that and how many points you want to subtract. Support forums, stackoverflow.com etc. should be a good place to ask a question like this.

One another userpoints thing you might need it is get the points a user currently has: "userpoints_get_current_points($uid)". You can for example multiply that with 0.1 if you want to deduct 10% of the points.

Feel free to re-open this issue (Remember to mark issues as fixed if they are) if you have more specific questions.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.