How to replace a Token in the PHP evaluation of a Rule? I'm trying to grant Userpoints to users with a Rule. The Rule first calculates two integer values 'New value' and 'Old value'. Debugging these numbers shows that there's no problem with them. Naturally, I tried awarding the points with an action "Grant points to a user" and I'm using the following code in the PHP evaluation:

if ($value &gt; 5) {
  return 0;
}
else {
  return token_replace('[new-value]');
}


where the default $value is old-value.  As the [new-value] token is available in the data selectors of the 'Points' section of the action, I suppose that one can use it in the PHP evaluation too. Therefore, after reading Token Replacements, I thought my code should work, but it doesn't: the Userpoints aren't granted to the user.

There's definitively something wrong with the Token, because the Rule is executed correctly when I use 1 instead of token_replace('[new-value]').

What am I doing wrong and how can I solve this?
I still don't know what went wrong, but I've solved the problem in an alternative way. Everything works fine when you follow the steps underneath.


Save the integers Old value and New value as variables.
Add a third variable Result. Thanks to step 1, one can use $old_value and $new_value in the PHP evalution of this variable. I've used this code:

if ($old_value &gt; 5) {
  return 0;
}
else {
  return $new_value;
}

Convert Value to an integer Final value.
Award Final value Userpoints to the user of your choice.