Support Forum

Cubepoints Rank Display

JT Josh Thomas
Josh Thomas
Member

Hi folks.

I’m using the Cubepoints plugin and was able to successfully show the points total in my user info on a post!
Pretty impressed with myself, since I don’t know jack about php, just followed the codex.

What I’d like to know now is, what is the code that I place into TopicView.php that displays the rank I created within the plugin? For instance, if I have 27 points, it’s associated with a rank of “Getting Started” that I set up in the admin. How can I make that rank show up in the red circle of the image attached?

Just a humble request in advance: words like string, array, call, etc mean nothing to me. I just need a line of code that I can paste into the proper area on TopicView.php. Anything more sophisticated will likely make my head explode.

Thanks very much!

Thanks!Screen-shot-2012-10-17-at-1.19.33-PM.png

17 Answers

New Answer

MP Mr Papa
Mr Papa
Member

Not sure I understand… you talk about cubepoints, but then switch to rank…

is this the forum rank?  or some rank within cubepoints?  if the latter, you will have to use the template tag or shortcode provided by the wp cubepoints plugin…

JT Josh Thomas
Josh Thomas
Member

Thanks for your reply.

I am talking specifically about rankings set up within the Cubepoints plugin, apologies for the confusion.

As for the template tag or short code, I have absolutely no idea where to even begin looking for those. I read the codex on template tags, but that was no help.

I’d be happy to use either of those, but where do I find them?

MP Mr Papa
Mr Papa
Member

if you are looking for a cubepoints rank, you need to look within that wp plugin – not simple press…

took a 15 second look at the plugin, seems you want something like:

if (is_user_logged_in()) echo ‘Rank:’.cp_module_ranks_getRank(cp_currentUser());

but have not tested it… again, its a cubepoints function…

JT Josh Thomas
Josh Thomas
Member

Thanks. That sort of worked. However, I believe that’s the code that shows on a widget when the user is logged in, because it shows the same rank as mine for every other member as well. Meaning, every instance of this code will only show the rank of whoever is logged in and not the individual members.

The reason I’m asking on this forum is because you provide great information in your codex about how to display the points (see screenshot). This is almost exactly the same thing, and it’s probably stored in a similar area. It’s just that I have no idea where to look.

Can you help me find the line of code I need to insertScreen-shot-2012-10-18-at-11.15.44-AM.png?

MP Mr Papa
Mr Papa
Member

Ah, yes. Had just copied their code. You will want to use the post user vs current user. Problem is I don’t know if they are passing user id or user object. And I wont have access to code until tonight.

Try changing it to $spThisPostUser

JT Josh Thomas
Josh Thomas
Member

Ok, tried this:

if (is_user_logged_in()) echo ‘Rank:’.cp_module_ranks_getRank($spThisPostUser());

…but got a fatal error. Forgive my ignorance, but I probably didn’t fully understand your suggestion. I’d bet this is a fairly easy fix for someone like you once you’re able to see the code tonight. But as for me, you’ll have to be fairly specific on exactly what I need to put exactly where. Hope that’s ok.

Thanks again for looking into this.

JT Josh Thomas
Josh Thomas
Member

That fixed the error, but only recreated the original issue (all ranks are the same).

BR Brandon
Brandon
Member

Josh Thomas said
That fixed the error, but only recreated the original issue (all ranks are the same).

Probably needs the user ID. Try

if (is_user_logged_in()) echo 'Rank:'.cp_module_ranks_getRank($spThisPostUser->ID);

But I don’t think you want the check to see if logged in if using it in the TopicView file by the poster’s avatar. So

So just

echo 'Rank:'.cp_module_ranks_getRank($spThisPostUser->ID);
JT Josh Thomas
Josh Thomas
Member

Brandon,

At the moment, that seems to be the fix! Thank you both for addressing this promptly.

BR Brandon
Brandon
Member

Josh Thomas said

At the moment, that seems to be the fix! Thank you both for addressing this promptly.

Good deal. You could probably use that first example by Mr. Papa if you wanted to put the logged in user’s rank next to his Avatar at the top too.

It would be nice if we could add the CP ranks info to the codex for others. I don’t really have the time right now, I am doing another Codex project, but we are always looking for volunteers. ;)

MP Mr Papa
Mr Papa
Member

correct. user id…

and you dont want to check logged in, but whether a user or not…. so

if (!empty($spThisPostUser->ID)) echo ‘Rank:’.cp_module_ranks_getRank($spThisPostUser->ID);

if you dont have guest posters, you eliminate the check…

JT Josh Thomas
Josh Thomas
Member

Great. That all seems to be working smoothly. Now, one final question…

Everything else in this section is centered. How do I center this?

BR Brandon
Brandon
Member

Josh Thomas said Everything else in this section is centered. How do I center this?

Cool,

I have not looked at the CSS used by CP and it’s rankings but you could try using the SP centering class.

Something like:

echo '<div class="spCenter">';
echo 'Rank:'.cp_module_ranks_getRank($spThisPostUser->ID);
echo '</div>';

If that doesn’t work I would probably need to see the actual site for recommendation.