This is what I have right now,
http://pastebin.com/4FGpJpvn
First I got undifined Variable for $topic_id so I added the $topic_id = 0; at the code, Zero stands for getting the topic ID from the loop ?
Paste the full code again?
Actually that was naive of me, and I now have figured out the problem, but not the fix. Here is what actually happens:
I upload items to website also, but sometimes in future the same exact item may be in the update, I would then end up with domain-name/item domain-name/item2 domain-name/item3 These are duplicates, I simply delete all these by running this code:
DELETE bad_rows.*
from wp_posts as bad_rows
inner join (
select post_title, MIN(id) as min_id
from wp_posts
group by post_title
having count(*) > 1
) as good_rows on good_rows.post_title = bad_rows.post_title
and good_rows.min_id <> bad_rows.id;
This is what is deleting all the forum posts 100%, checked and tested it. The only thing is, I do need to run this. Is there a way to exclude in this code bbpress posts, or something?
Hey hey … I can’t go back to edit my code … the second piece of code … the first line has just got one & and should have TWO!
So it should read:
if ( true === $r['hierarchical'] && 1==2) {
$walker = new BBP_Walker_Reply;
$total_pages = ceil( (int) $walker->get_number_of_root_elements( $bbp->reply_query->posts ) / (int) $replies_per_page );
} else {
$total_pages = ceil( (int) $bbp->reply_query->found_posts / (int) $replies_per_page );
And don’t forget this is totally an experiment at my end here … but it’s working well on two local dev installations and our dev server setup 🙂
Just realized that the ‘similar’ thing for topics doesn’t exist. Your method for topics is correct, and you’ll need something like this after you’ve the $words array:
$words = array_unique( array_merge( $words, wp_get_post_terms( $topic_id, bbp_get_topic_tag_tax_id(), array( 'fields' => 'names' ) ) ) );
if ( !empty( $words ) )
wp_set_post_terms( $topic_id, $words, bbp_get_topic_tag_tax_id(), true );
The top of the code should read as (to accept the $topic_id passed by do_action):
add_action( 'bbp_new_topic', 'shmoo_auto_save_tags', 10, 1 );
add_action( 'bbp_edit_topic', 'shmoo_auto_save_tags', 10, 1 );
function shmoo_auto_save_tags( $topic_id ) {
Again, untested, but should work in principle.
Better hook it to bbp_new_reply_pre_set_terms here: https://bbpress.trac.wordpress.org/browser/trunk/includes/replies/functions.php#L371 and return the $words array after joining in the supplied $terms array. Similarly for topic.
I’d also suggest to have this at the very beginning:
if ( !bbp_allow_topic_tags() || !current_user_can( 'assign_topic_tags' ) )
return $terms;
Okay as the title says I need a little help finishing a small bbPress plugin.
Right now it checks each topic content against the bbPress topic-tags created from the back-end ( only those are assigned not empty tags ) and if there are matches between the tags and content it echo’s those matches found.
The only deal-breaker here is how to add those matches found the $word Variable to each topic tags when you create a new topic or edit a topic fron the front-end.
I believe you have to work with those two actions:
add_action( 'bbp_new_topic', 'function_name', 10, 5 );
add_action( 'bbp_edit_topic', 'function_name', 10, 5 );
But how do you make the connection to the database table or how it’s called.
This is the code I already made.
http://pastebin.com/d7ZEifNb
This Plugin was an idea because of this topic.
Opinion: Tags in bbPress, do you like it or frustration to maintain?
Some help from anybody who knows PHP and creating WP Plugins would be very cool.
Thanks..
Actually, just found out how to “fix” this … but not sure of the impact.
In file bbpress/includes/replies/template.php there’s two places –
Around line 174, I’ve remarked out the IF statement –
// Set posts_per_page value if replies are threaded
$replies_per_page = $r['posts_per_page'];
/*if ( true === $r['hierarchical'] ) {
$r['posts_per_page'] = -1;
}*/
And around line 250, I’ve made the IF never be true just to try it out –
if ( true === $r['hierarchical'] & 1==2) {
$walker = new BBP_Walker_Reply;
$total_pages = ceil( (int) $walker->get_number_of_root_elements( $bbp->reply_query->posts ) / (int) $replies_per_page );
} else {
$total_pages = ceil( (int) $bbp->reply_query->found_posts / (int) $replies_per_page );
And that works. But what’s the impact of doing that beyond fixing what I wanted? Am I missing something?
Untested, but this should work (put it in theme’s functions.php):
remove_filter( 'bbp_get_reply_content', 'bbp_rel_nofollow' );
remove_filter( 'bbp_get_topic_content', 'bbp_rel_nofollow' );
If you also want to remove nofollow from users’ urls, add this too:
remove_filter( 'bbp_get_reply_author_link', 'bbp_rel_nofollow' );
remove_filter( 'bbp_get_topic_author_link', 'bbp_rel_nofollow' );
muyilleum, put those two lines in your theme’s functions.php after <?php. On pressing save, that code will automatically load and remove the roles. You can then remove the lines because they would not serve any further purpose.
This worked for me. I dropped the code into my functions.php, then removed them when it was done.
Cheers,
Jeff
This seems to work – there may be a better way…
In an over-ride of content-single-forum.php, do something like this:
if ( // some condition ) {
$my_r['meta_query'] = array(
array(
'key' => 'my_key',
'value' => 'my_value',
'compare' => '=',
)
);
}
else
$my_r = '';
Then change bbp_has_topics() to bbp_has_topics( $my_r )
Hello everyone,
Recently we’ve been starting to use bbPress and it seems to be a very rich expansion of WordPress. What I wonder about is this: is it possible to show all sticky topics on your front page, using a shortcode? Say I have a part of my site that is the forum, I would still want to show the sticky topics in a widget in a sidebar, right from the start on the home page. I’ve read about shortcodes listing most popular or most recent topics, but is this possible for stickies too?
Many thanks,
Lucas
It seems that content-single-forum.php is the template to over-ride.
So do I have to pass in WP_Query meta_query args to bbp_has_topics() ?
I’d like to only gather the appropriate topics, so using the supplied apply_filters
apply_filters( 'bbp_has_topics', $bbp->topic_query->have_posts(), $bbp->topic_query );
seems inefficient.
Or is there an easier way?
I managed to remove the area at the header of forum which states this topic has x amount of details etc by placing this code in functions.php
add_filter( ‘bbp_get_single_forum_description’, ‘ja_return_blank’ );
add_filter( ‘bbp_get_single_topic_description’, ‘ja_return_blank’ );
function ja_return_blank() {
return ”;
}
How do I now remove the actual voices part and the numbers which shows, can I do this through functions.php also.
Thanks for help.
Anonymous User 13302461Inactive
Hi. When viewed on an ipad, some of the forum “start topic” or “reply to topic” area is not displayed. For some reason it is not shrinked and the div stays too wide to display all of it, as you can see the bbcode buttons are not all displayed as they are all on 1 row.
However, this div in question shrinks on PC and the bbcode buttons are displayed on multiple rows.
Has anybody got any idea why please?

Thanks for the reply Stephen,
However I’m not sure the shortcode [bbp-forum-index] will help me.
My blog is at website.com/blog. If I create a page called called ‘test’ with that shortcode then it will be at:
website.com/blog/test/
Also that’s just the index page. The actual forum posts/categories etc will still be at website.com/blog/forum/*
Thanks,
Sam
I added a simple check in bbpress/inlcudes/users/capabilities.php to see whether the current user has a role in the current blog, before giving them a forum role:
/** Ready *****************************************************************/
// Load up bbPress once
$bbp = bbpress();
// Get whether or not to add a role to the user account
$blog_role = bbp_get_user_blog_role( $user_id );
$add_to_site = bbp_allow_global_access() && $blog_role != false;
With that in place I can reset all my previous changes so that the default setting for global access is true.
I’ve edited the text in Forums -> Settings to show that ‘global access’ is really now just ‘site access’.
Ideally this would be a separate option in Forums -> Settings, to limit automatic forum access to site members. I will submit a patch if I get the time.
The problem with the default settings is that in a large Buddypress-type site, every time I visit a new site when logged in, that site is added to my My Sites list.
Hey guys, I’m new to BBpress. so I have a few questions that I’m hoping can be solved here.
The theme I’m using has 2 different custom Sidebars and other features that can be enabled and disabled on the page settings.
I’ve created a custom Page template for the forum and tried using the Shortcodes to implement BBpress on the page and it works but once you click something on the page it directs back to the original template. Is there a way to have the whole forum and index and everything on the one page?
Thanks
Great, glad it all worked !
If you’re not using a child theme, then any theme upgrade may overwrite your functions file, so keep a note of the final code you used, as you may need to add it back.
You are correct. The execution of the hooks when creating a new topic was a misobservation on my side. Sorry about that!
The bbp_new_forum hook firing only when a forum is created outside wp-admin is interesting information. Thanks for clearing that up.
I have already worked around the ‘missing’ hooks by tying into the save_post hook. Its not exactly what i would call elegant, and it requires some additional checks to make sure my callback was executed for the right event, but it does the job.
So, the only thing that is left for me to ask is: Why isn’t there an intuitively named hook for when one creates a forum from the backend? Or is there one that i am missing? 🙂
Thank you for your response!
Hi Robin,
That has worked but with a small issue….the image is displaying far bigger than the uploaded file which is 75x75px. What do I need to change in that code to help the formatting?
http://techdev.kemikalkitchen.co.uk/forums/forum/android/
This is on my test server but is the same environment that the final site will reside in.
Many thanks
That doesn’t seem right. bbp_new_forum will only fire when forums are created outside of wp-admin, like in a BuddyPress Group Forum. If you want to add meta when any new forum is created, you’ll likely need to hook into WordPress’s wp_insert_post action, instead.
Add this in a custom plugin or the functions.php of your active theme:
add_filter( 'bbp_allow_global_access', '__return_false' );
You’ll want to undo the edits you’ve made to bbPress’s files, also.