With a few hacks, this plugin still works good enough to maintain a score for each user based on their posts.
But the plugin relies on some old functions that belong to bbPress 1. And when you upgrade to bbPress 2, these functions will no longer be avaiable, and the plugin will cause errors.
So to make it work, I replaced instances of:
bb_usermeta()
and bb_get_post()
with get_user_meta()
and get_post()
I haven’t fixed the admin screens, because I don’t really need them right now. But these small fixes will make the core of it work for now.
]]>I had 2 main problems getting this plugin to work:
1. It doesn’t seem to make any attempt to insert points/title info in the topics pages.
2. The function to go through all posts to recount fails.
I’m sure this plugin will be fixed at some point. But for now, I did the following to make it work for me. Perhaps someone else will find it useful:
1. NOTHING SHOWS UP NEXT TO USER
I don’t see how anything should be able to show up, because the plugin doesn’t hook into the bbpress theme hooks for displaying something in the author pane of a reply.
I found it to be most easy to just insert code in the BBPress template file (loop-single-reply.php):
Insert before or after the line
<?php do_action( 'bbp_theme_after_reply_author_details' ); ?>
this:
<?php
$rank = autorank_get_rank(bbp_get_reply_author_id(bbp_get_reply_id()));
echo '<div class="author-rank">' . $rank[0] . '</div><div class="author-points">' . $rank[1] . ' points</div>';
?>
.. or something similar
2. RE-COUNTING FAILS
On the Admin -> Tools -> Forum page (where all the re-count posts, topics, etc. etc. for the forum in general is) and at the bottom there is a checkbox saying “Re-score all posts.”. Check this and run to have it go through all users’ post and recount all the user scores.
The function that does this is autorank_recount()
in the plugin’s bbp-autorank.php
file.
This fails for me however for 2 reasons. Firstly, the wordpress get_post function is called with some params, including the “post_author”. For some reason this results in an SQL select statement WITHOUT post_author in the WHERE clause. So WP tries to pull out all forum replies from the database one time per user.
To circumvent this, I’ve changed the function to this to bypass WP’s post retrieval:
function autorank_recount() {
global $wpdb;
$user_ids = $wpdb->get_col( "SELECT <code>ID</code> FROM <code>$wpdb->users</code>" );
foreach ( $user_ids as $id ) {
$user_score = 0;
$post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM wp_posts WHERE post_author = %d AND post_type IN ('reply', 'topic') AND post_status = 'publish' ORDER BY ID ASC", $id));
foreach ( $post_ids as $post_id )
$user_score += autorank_get_post_score( $post_id );
update_user_meta( $id, 'autorank_score', $user_score );
}
return array( 0, __( 'All scores recounted.', 'autoscore' ) );
}
Even still the function fails for me, but this is because I have over 200,000 replies in the forum, and that simply takes longer than the standard PHP timeout to go through.
This I solved by calling the autorank_recount() from another file with PHP timeout set to 10 minutes or so.
—-
I know this solution is ugly, but it’ll do for me, so someone else might find it useful.
]]>broken
]]>Hello, this plugin isn’t working at all.
People have been telling you for awhile also.
Please get to working, would be a useful plugin. Thank you.
]]>I’ve installed Autorank and it’s not doing anything. It doesn’t display the rank, the point counts, nothing. There’s another thread with this issue is but it is marked as Resolved when it is not.
Any support is appreciated.
]]>Hello,
I have installed bbp autorank but it is not displaying the amount of points, or the rank list or any thing to do with that plug-in.
]]>