How can I check whether one's current User Points are negative with the Rules module? [closed]

StackOverflow https://stackoverflow.com/questions/19607272

سؤال

My question is pretty straightforward: how can I check whether a user's current amount of User Points is negative with the Rules module? I'd like to create an action that should be activated when the user is granted User Points. The event is set, but I don't know how I can set the condition.

Edit: I enabled the PHP filter module in order to get the 'Execute custom PHP code' option in my Rule's conditions. (I didn't know that I had to do this before...) I used this code to check whether the user's User Points are negative:

global $user;
$num_pts = userpoints_get_current_points($user->uid, 'all');
$neg_pts = $num_pts < 0;

Unfortunately, it's always evaluated as 'false', even when the amount of User Points is negative. I've also tried this:

$num_pts = userpoints_get_current_points([userpoints-transaction:user]->uid, 'all');
$neg_pts = $num_pts < 0;

But that didn't work either (same reason). I don't get any error messages in both cases.

Are these code snippets wrong? How does the correct one look like?

هل كانت مفيدة؟

المحلول

I found the correct code:

global $user;
$num_pts = userpoints_get_current_points($user->uid, 'all');
if ($num_pts < 0) {return TRUE;}

Just use this snippet in an Execute custom PHP code condition. It's as simple as that!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top