User ranking display position
-
Is there a way to display the user position on User Ranking page??
Now :
user1
user2
user3User Position display.
1.User1
2.User3
3.User4Thank you.
-
Since there is no paging in free version, I’ll try to check it in the update tonight.
You can do this changing 3 lines of file wcp-reports.class.php:
1) Search for function user_ranking() and inside it locate the command
foreach ($result as $row) {
2) Before this command, create a variable
$pos = 1;
3) Inside the foreach, look for the line:
$output .= "<tr $style><td class='wcup-user'>".($avatar ? get_avatar( $row->ID, '16', '', $row->display_name ) : '').' '.$row->display_name."</td><td class='wcup-points'>$row->total</td><td class='wcup-review'>";
Change it to:
$output .= "<tr $style><td class='wcup-user'>".($avatar ? get_avatar( $row->ID, '16', '', $row->display_name ) : '').' '.$pos . '. ' . $row->display_name."</td><td class='wcup-points'>$row->total</td><td class='wcup-review'>";
4) Finally, before closing the foreach block, add
$pos++;
.Your code will look like this:
$pos = 1; foreach ($result as $row) { if ($row->ID == $curr_user_id) { $style = "style=\"$highlight\""; } else { $style = 'class="wcup-row"'; } $output .= "<tr $style><td class='wcup-user'>".($avatar ? get_avatar( $row->ID, '16', '', $row->display_name ) : '').' '.$pos . '. ' . $row->display_name."</td><td class='wcup-points'>$row->total</td><td class='wcup-review'>"; if (get_option($this->prefix.'player_predictions')) { $output .= "<a class='review-link' title='".__('Predictions', WCP_TD)."' href=\"".get_option($this->prefix.'player_predictions')."&wcp=predictions&user=".$row->ID."\"><img src='". WP_PLUGIN_URL."/".WCP_TD ."/images/predictions.png' /></a>"; } $output .= "</td></tr>" . PHP_EOL; $pos++; }
This can be seen in https://www.wcp.net.br/ranking-of-players/
Hi landoweb,
Thank you very much for this solution.
I’d just add something to the above code to cater for members having equals points. Example:
1. member1 60pts
2. member2 58pts
2. member3 58pts
3. member4 55pts$pos = 1; $oldTotal = -1; foreach ($result as $row) { if($oldTotal > $row->total){ $pos++; } if ($row->ID == $curr_user_id) { $style = "style=\"$highlight\""; } else { $style = 'class="wcup-row"'; } $output .= "<tr $style><td class='wcup-user'>".($avatar ? get_avatar( $row->ID, '16', '', $row->display_name ) : '').' '.$pos . '. ' . $row->display_name."</td><td class='wcup-points'>$row->total</td><td class='wcup-review'>"; $oldTotal = $row->total; if (get_option($this->prefix.'player_predictions')) { $output .= "<a class='review-link' title='".__('Predictions', WCP_TD)."' href=\"".get_option($this->prefix.'player_predictions')."&wcp=predictions&user=".$row->ID."\"><img src='". WP_PLUGIN_URL."/".WCP_TD ."/images/predictions.png' /></a>"; } $output .= "</td></tr>" . PHP_EOL; }
@cioka99 and @farhaz1907
Do you could inform link their websites to I see if this issue is resolved?
I have added a small improvement onto farhaz1907’s solution.
Example:1. member1 60pts
2. member2 58pts
2. member3 58pts
4. member4 55ptsAs you can see the member4 is ranked 4th and not 3rd as in farhaz1907’s solution.
$pos = 1; $count = 1; $oldTotal = -1; foreach ($result as $row) { if($oldTotal > $row->total){ $pos = &count; } if ($row->ID == $curr_user_id) { $style = "style=\"$highlight\""; } else { $style = 'class="wcup-row"'; } $output .= "<tr $style><td class='wcup-user'>".($avatar ? get_avatar( $row->ID, '16', '', $row->display_name ) : '').' '.$pos . '. ' . $row->display_name."</td><td class='wcup-points'>$row->total</td><td class='wcup-review'>"; $oldTotal = $row->total; if (get_option($this->prefix.'player_predictions')) { $output .= "<a class='review-link' title='".__('Predictions', WCP_TD)."' href=\"".get_option($this->prefix.'player_predictions')."&wcp=predictions&user=".$row->ID."\"><img src='". WP_PLUGIN_URL."/".WCP_TD ."/images/predictions.png' /></a>"; } $output .= "</td></tr>" . PHP_EOL; $count++; }
hello!
can you help make the same system, in page with result of match, you have group of ho much points have users, and how many users make predict for 1 team, egal and other team.how you do it?
User ranking display position
it would be done in next plugin versions?yes , i will post the code tonight. I am now editing a little bit the user profile ranking.
I want to display in user ranking also : Avatar, Position in ranking table , How many victories user has predicted , how many draws, how many correct scores , etc.The ranking position will be present in version 1.9.2.
Regarding the customizations made ??by cioka99, will not be present because they are a bit more complex.
- The topic ‘User ranking display position’ is closed to new replies.