[wp-forums] Upgrades to WordPress.org forums

Mark Duncan wp-t31os at ntlworld.com
Wed Jul 14 13:35:40 UTC 2010


On 10/07/2010 22:56, Michael D Adams wrote:
> On Sat, Jul 10, 2010 at 12:05 PM, James Huff<macmanx at gmail.com>  wrote:
>> 1. In profiles, "Recent Replies" are no longer sorted by most recent reply. They appear to be sorted by only the initial reply. This will cause long-term "project" topics to be buried in our profiles.
>
> Not fixed - this will take some thinking.
>

If you're talking about the regular non BuddyPress profile pages, 
they've never sorted by most recent reply as far as i've observed.

The BB_Query class doesn't really work very well for grabbing post and 
topics in that manner (as far as i can see).

Assuming Michael isn't against using a custom query it could work with 
something like.

Example:
$recent_replies = $bbdb->get_results("
	SELECT t.topic_title,t.topic_id
	FROM bb_topics t
	JOIN bb_posts pp ON pp.topic_id = t.topic_id
	WHERE EXISTS(
		SELECT p.poster_id FROM bb_posts p WHERE p.poster_id = 1 AND 
p.topic_id = t.topic_id
	)
	GROUP by t.topic_id
	ORDER by t.topic_time DESC
");
NOTE: The poster ID above is just for testing(local install), that would 
obviously need to be the ID of the user whose profile page is being viewed.

I couldn't find any proper docs for the BB_Query class and it's usage 
doesn't appear obvious (maybe i'm not just not pro enough yet), but the 
above seems to be heading in the right direction for grabbing threads 
where a poster has made a reply and sorting my most recent response.

Query has room for refinement i'm sure.

Obviously there are no checks on whether the topics are deleted or 
whether posts are marked as spam, was simply for illustration of how a 
query could pull threads based on last reply. The query does not take 
into account whether the user was the last person to reply.

Couldn't help myself, it's the one thing i've been desperately desiring 
on the forums for some time.

I'm a bbPress novice really (it's still just PHP/MySQL though), very 
little use, so if i'm way off on this, just tell me to shush.

Thought i'd put it out there anyway... :)

Mark / t31os


More information about the wp-forums mailing list