bbPress New Topics Plugin
by Bandicoot Marketing on | Posted in Downloads | 33 comments
With the refresh of Themes by bavotasan.com I reinstated the bbPress support forum. Way back in the day, I used Vanilla forum and there was one feature they offered that I really miss: whenever a new topics was created or there was a unread reply, a ‘New’ label was added to easily identify those topics.
It took some time of digging into the bbPress code to figure out how to accomplish the same thing, but I managed to get it working. It’s a small plugin that does nothing more than what the description says:
Displays a “new” label on topics that are unread or have unread replies for all keymasters and moderators.
Try it out and let me know if you encounter any issues or if you find it helpful.
Thank you! The “New” Label appears. But it won’t disappear. How does the plugin work in detail? With cookies? Allthough i read the Post and restarted the browser, the label still appears. I would expect it then will not show anylonger.
The plugin stores the topic ID in the keymaster/moderator user meta. If a new label appears, it should disappear once you open the topic. There is a hook that removes the ID from the array.
Do you have any cache plugin installed?
thank you for this pro info
I have same problem with @nicmare, I already posted it at http://wordpress.org/support/topic/new-does-not-go-away-after-view?replies=2#post-5295090
Hi
I just installed BBPress on Magazine Premium. I added a forum with a short code and set the page to full width to enable forum sidebar etc. It is not displaying the sidebar.
Setting the page to full width removes all sidebars.
It is not displaying sidebars on the page that hosts the forum (has the embed code) but when you click to enter the forum the regular sidebar is showing.
Would this have something to do with adding the BB sidebars in the php code?
Is this information from the The BBPress support page relevant ?[http://codex.bbpress.org/step-by-step-guide-to-setting-up-a-bbpress-forum/#8-make-sure-bbpress-uses-the-page-template-we-want]
“8. Make sure bbPress uses the page template we want
By default bbPress will use a page template in your theme root folder .
It will look for the existence of several files in the following order, using the first one it finds.
plugin-bbpress.php
bbpress.php
forums.php
forum.php
generic.php
page.php
single.php
index.php
Typically most (but not all) themes have a page.php, so if you do nothing else, chances are that that’s the one it will use.
But you may want bbpress to display differently than the template it chooses for instance you might want your forum on a full width page and find that it uses a sidebar template, or visa versa.
You can even find that bbPress appears differently when displaying the forum index than it does with topics, which is probably not what you want. Nowadays theme developers will quite often use “if…” code within the page template to change the display of types of pages. Since topics share the same characteristics as posts, but the index page is more like an “about” page, the theme can believe that it should show then in different ways.
If bbPress is using the page layouts you want, then that’s fine, and you can ignore the rest of this section.
If not, then the following will let you set bbPress up in the way you want.
You theme will have page templates in the root of the directory, that is :
wp-content/themes/%mytheme%/ where %mytheme% is your theme’s name.
You’ll need to find the name of the page template that you want to use. Look in your theme’s directory – normally they are named very obviously – eg pagefullwidth or pagesidebar. If it’s not obvious, you can see what the template is called by editing a page that has the correct layout, and looking at the name of the template on the right hand side of the edit screen in a panel under the publish/update panel. If you then open the various page.php files, you see that they are named in the first few lines, so you can easily match the name.
So once you know which page template file you need, copy this and rename the copy to bbpress.php
Place this file in the root of your theme ie wp-content/themes/%mytheme%/bbpress.php where %mytheme% is your theme’s name.
bbpress will the use this file for all it’s pages.
If you want to customise the layout for your forums, you can then do this within this file.
We’ll do all that now with a forum sidebar.”
Sorry c.bavota I just saw the bbPress WP Tweaks page which gives the following options
Default forum wrapper
Select template file that you prefer bbPress rendered in. Make sure template file is present in your theme directory. If sidebar is not displaying make sure you put some wodgets to “bbPress sidebar” in widgets page then try different forum wrapper from this list.
plugin-bbpress.php
bbpress.php
forums.php
forum.php
generic.php
page.php
single.php
index.php
Files with Bold text exist.
—
Currently ” bbpress.php” is selected. Is that the right one?
Apologies for the huge previous post I guess it can be removed?
Gideon
It still isn’t working. The problem is this: the page that hosts all there forums (with the short code) displays in full width. But when I click on any of the forums it activates the sidebar.
Am I right in thinking that BBPress is using a template with the sidebar?
I duplicated the pages.php and renamed it bbpress.php and adde it to the Child theme. Can I modify that file to remove the sidebars?
The problem is that it uses the custom page you created for the forum home page, so you can set the full width. But then it just uses the default page.php file which doesn’t actually exists as a “real” page so you can’t set it to full width. Doing what you mentioned above should allow you to have more control over the forum pages.
Thanks
Can you provide the code to add to the bbpress.php in the child theme to make it full width please?
Thanks
Gideon
Please ask this question in the support forum.
Thank you for sharing, but it’s not working for me. I have a cache plugin installed, but this seems not to be the problem. What else can I do?
Regards Klas
The cache plugin would be the problem, unless you don’t use it on your forum.
Is there any way to let all users see the new posts, instead of just mods and admin.
I looked at the code, added in bb_participant, but it didn’t work.
You would have to create a new array of users in the
bbp_get_admins
function, and then merge that array with the others.nice
Hey, great plugin! Thanks for taking the time to work this one out. I have a drive to know this with my new website theme. I wish I could find one that works well and doesn’t cost a lot. Any advice?
What exactly are you looking for?
I later learned that I did not know what to do plug-in settings give you many thanks for the information
i guess that will work just cool with my professional photography site coming in the strrets of india as the best photographer and thanks for this crazy plugin which can help greatly on my website services.cordavida.com & http://www.cordavida.com for the love of art – professional photographers from india
I want to change this so that all my registered users can get the “new” notifications, how do I do that?
Not too sure how to do that exactly, but it would require modifying this section:
I changed the method to
public function bbp_get_admins() {
$keymaster = get_users( array(
‘role’ => ‘bbp_keymaster’,
) );
$moderators = get_users( array(
‘role’ => ‘bbp_moderator’,
) );
$participant = get_users( array(
‘role’ => ‘bbp_participant’,
) );
return array_merge( $keymaster, $moderators, $participant );
}
I am waiting for my users to confirm that it works. Then I am going to add “new” tags to forum headers.
made a couple more additions to the plug in:
Added “New” notification on forum index and fixed the unread not being reset on being read problem I was having
public function __construct() {
add_action( ‘admin_init’, array( $this, ‘admin_init’ ) );
add_action( ‘bbp_enqueue_scripts’, array( $this, ‘bbp_enqueue_scripts’ ) );
add_action( ‘bbp_new_topic’, array( $this, ‘bbp_new_topic’ ), 10, 4 );
add_action( ‘bbp_new_reply’, array( $this, ‘bbp_new_reply’ ), 10, 5 );
add_filter( ‘bbp_get_topic_class’, array( $this, ‘bbp_get_topic_class’ ), 10, 2 );
add_action( ‘bbp_theme_before_topic_title’, array( $this, ‘bbp_theme_before_topic_title’ ) );
add_action( ‘bbp_theme_before_forum_title’, array( $this, ‘bbp_theme_before_forum_title’ ) );
//add_action( ‘bbp_theme_before_topic_author’, array( $this, ‘bbp_theme_before_topic_author’ ) );
//bbp_template_before_single_topic
add_action( ‘bbp_template_before_single_topic’, array( $this, ‘bbp_template_before_single_topic’ ) );
}
//bbp_template_before_single_topic
public function bbp_template_before_single_topic() {
$user_id = get_current_user_id();
$topic_id = bbp_get_topic_id();
$new_topics_array = (array) get_user_meta( $user_id, ‘bbp_new_topics’, true );
if ( in_array( (int)$topic_id, $new_topics_array ) ) {
if ( bbp_is_single_topic ()) {
//echo ‘************************************************************************************************************************’;
unset( $new_topics_array[array_search( (int) $topic_id, $new_topics_array )] );
update_user_meta( $user_id, ‘bbp_new_topics’, (array) $new_topics_array );
} else {
echo ” . __( ‘New’, ‘new-topics’ ) . ‘ ‘;
}
}
}
public function bbp_theme_before_forum_title(){
$user_id = get_current_user_id();
$forum_id = bbp_get_forum_id();
$new_topics_array = (array) get_user_meta( $user_id, ‘bbp_new_topics’, true );
global $wpdb;
$query = ‘SELECT post_id FROM pct_postmeta WHERE meta_key = “_bbp_forum_id” AND meta_value = “‘ . $forum_id. ‘”‘;
$result = $wpdb->get_results($query);
foreach($result as $row){
$post_id = $row->post_id;
if(in_array((int)$post_id, $new_topics_array)){
echo ” . __( ‘New’, ‘new-topics’ ) . ‘ ‘;
break;
}
}
}
Thanks Thaddeus, I tried your code on the plugin, but i get syntax errors with the last bit you posted.
could you possibly help…..
Here is a literal copy and paste from my working site:
[CODE REMOVED]
If that doesn’t work drop me a line at t_aid (at) hotmail dot com and I will email a copy of the file.
Please post your code using something like GIST or Pastebin. That way nothing will accidentally appear incorrect due to how WordPress converts certain characters. Thanks.
Okay try this http://pastebin.com/Cn1myRDE
I plan on adding one more change to this plug in when I have some spare time to add “new” to categories when a sub-forum has new posts.
Sounds great. Please add a description to explain what your changes are doing and which functionality you’ve added. In the end it might make sense to merge our plugins and add some options to turn things on/off. 😉
Thanks !!
Great plug in
juani