Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Plugin: Latest Replies


LMD
Participant

@louisedade

Hello again, just finished examining code. There are two issues.

The first issue is that the blog entries you are posting to bbPress appear as closed topics. This problem is totally unrelated to the “Add Titles to Replies” plugin, which does not touch the ‘topics’ table in the database at all. I suggest you enquire with the ‘bbPress Post’ author about this. Did you update that plugin on your forum at the same time as installing mine? That could be the source of the problem.

Now, having said all that, the second issue is going to seem to contradict it. What I mean is, are you sure the topics are ‘closed’, or is it just that the content does not appear – that is, is it a phantom topic?

This can occur when the ‘topics’ table gets updated, but the ‘posts’ table does not for some reason (usually a coding error). When you create a new topic in bbPress, you are actually simultaneously creating the topic and making the first post in that topic – so both tables get updated.

This is where the problem involves my “Add Titles to Replies” plugin, because we have altered the ‘posts’ table, which may be causing an error in the ‘bbPress Post’ plugin code (that plugin writes to the database in a different way to the bbPress core).

Still with me? Good…

Now, I do not have access to an integrated WordPress/bbPress installation, so I have made a stab in the dark at trying to fix this the easy way. I’ve written a very short function (a bit of a hack really) that you can add to the ‘bbPress Post’ plugin.

In the ‘bbPress Post’ plugin open the file called ‘bbpress_post.php’ and add the following code to the bottom of the page, just before the bottom PHP tag ?>

/* Ugly 'Add Titles to Replies' Hack by LouiseDade */
function bbpress_add_reply_title( $post_id, $topic_id ) {
global $wpdb, $otherdb;
$bb_table_prefix = bbpress_getoption('bb_prefix');

if (bbpress_getoption('bb_other_base') === "no") {
$topic_title=$wpdb->get_var("SELECT topic_title FROM ". $bb_table_prefix ."topics WHERE topic_id=$topic_id LIMIT 1; ");
$wpdb->query("UPDATE ". $bb_table_prefix ."posts SET post_title='$topic_title' WHERE post_id='$post_id' LIMIT 1");
} else {
$topic_title=$otherdb->get_var("SELECT topic_title FROM ". $bb_table_prefix ."topics WHERE topic_id=$topic_id LIMIT 1; ");
$otherdb->query("UPDATE ". $bb_table_prefix ."posts SET post_title='$topic_title' WHERE post_id='$post_id' LIMIT 1");
}
}

Next, scroll up to the bbpress_new_post() function and at the bottom, before the closing curly brace, add:

/* Added by LouiseDade - updates post reply title */
bbpress_add_reply_title( $post_id, $topic_id );

Then scroll up again to the bbpress_post_update() function and add the same code as above just before the closing curly brace again.

Re-upload the plugin with the changes made and try posting a WordPress entry.

If it works I shall jump around for joy, but unfortunately I have grave doubts about it. I think it might need to be done the hard-way, which involves rewriting some of the ‘bbPress Post’ plugin.

Good luck!

Skip to toolbar