3

I have set up the User Points module and want to show authors' points next to their name.

What is the simplest way to do this?

  • Where and how you want to display these things? – Shoaib Nawaz Jun 28 '11 at 1:59
  • Name in their posts? – Matthew Hui Jun 28 '11 at 4:06
  • Good question. I want to show next to their name in posts. (As an example, just like here, where user655 (me) currently has "74" above and Berdir has "7,643" below). – chipcleary Jun 29 '11 at 1:21
2

The API function to get the points is userpoints_get_current_points() *. Just call that function with the uid of the author and display the returned result.

* Note that my API documentation page only lists the Drupal 7 versions, this function works the same way in Drupal 6 and 7 but others might not.

| improve this answer | |
  • Ah, thanks. I should've said ... I know the function name. What I'm not clear on is where I should use it. What would be simplest is, e.g., if there were some hook I could call to alter the user name in posts. Or should I create a template? Sorry, I should have made my question more clear. – chipcleary Jun 29 '11 at 1:24
  • There is no common place to do this, you need to to this for example in comment.tpl.php for comments and node.tpl.php for nodes. You can also look at drupal.org/project/author_pane and drupal.org/project/advanced_forum, these modules provide this, among many other things, automatically for forum posts. – Berdir Jun 30 '11 at 15:30
  • FWIW, what I ended up doing was a little different. I am creating a custom module and used hook_preprocess to alter the "submitted" text. Thanks for the ideas! – chipcleary Jul 2 '11 at 22:31
  • @berdir is there a way to do this via the views and panels UI? – user12342 Apr 9 '13 at 10:53
0

I tried putting that code userpoints_get_current_points() * in comment.tpl.php but it seems that it does not work. I can not program by using PHP. Maybe I had to add something?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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