How to grant user User Points equal to certain fie

2019-06-03 14:14发布

问题:

I've a content type 'Content' with the field 'Value' (an integer) and a flag called 'Publish Content and grant points to user'. Every time a Content is flagged with this flag, I'd like to grant the Content's author some User Points, equal to the value in the 'Value' field.

I tried solving the first part of my problem with the Rules module like this:

*Event: A node has been flagged, under "Publish Content and grant points to user"

*Conditions: Content is of type 'Content'

*Actions: Grant points to a user: ...

However, it's impossible to pick flagged-node:field-value in the Points section. I also tried:

*Event: A node has been flagged, under "Publish Content and grant points to user"

*Conditions: Content is of type 'Content'

*Actions:

 - Calculate a value: `[flagged-node:field-value]` "+" 0. (Variable name = result)

 - Grant points to a user: ...

But then, the variable 'result' is not available. How can I solve this issue?

回答1:

I finally found a solution! I completed the second scenario (the amount of User Points is calculated) successfuly! Apparently, the User Points module didn't know that the calculation was an integer. Therefore, I had to add an extra action Convert data type: Target type: Integer, Value to convert: [result], Rounding behavior: Always down. I called it 'total' and granted the user this amount of User Points.