The registered users on my website can create nodes from a content type called 'Stuff'. I'd now like to display the author's User Points he/she had when he/she created the node. That means: the value shouldn't be updated when the author's User Points change in the future.

How can I do that? Can I do a similar thing for comments?

Can this be done with a code/dynamic/preprocess field, provided by the Display Suite module?

@arpitr's tip for using the Computed Field module seems a pretty good idea, but as I replied to his answer, I don't know anything about PHP. I tried the following code, but it doesn't work.

global $user;
$entity_field[0]['value'] = "userpoints_get_current_points($user->uid)";

2 Answers 2


Simply add one more field to the Stuff content type and use Computed Field module for adding that field.Since field is on content type so its value will be added while adding the node with the value of user points user will have while creating it,afterwards it will be same or depends on php code computing value for this field.

Computed Field is a very powerful field module that lets you add a custom "computed fields" to your content types. These computed fields are populated with values that you define via PHP code. You may draw on anything available to Drupal, including other fields, the current user, database tables, you name it. (Feeling the power yet? :) ) You can also choose whether to store your computed field values in the database with other content fields, or have them "calculated" on the fly during node views. (Although you should note that Views use requires database stored values.) This field is literally the Swiss Army knife of fields. So start cooking up your PHP based values!

  • The module's page says: "This module is intended to be used by PHP developers to insert & execute PHP code on a Drupal website. It does not provide a macro interface, a code builder or anything other than insert your working code here into this text area. You need to have a good working knowledge of PHP and the Drupal API to use this module." Unfortunately, I can't work with PHP yet. Can you give me the code snippet I need?
    – Jeroen
    Oct 9, 2013 at 21:13
  • I've updated my question. Perhaps you can help me a bit with the code?
    – Jeroen
    Nov 28, 2013 at 9:39

I've achieved this by adding a new integer field 'Userpoints' to comments and nodes. After that, I created a rule for the events "After saving a new comment/new content" and used the action "Set a data value" to set the 'Userpoints' field's value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.