bbpress doesn’t load the the necessary scripts (reply.js etc) when embedding a topic as a shortcode. This is because of the conditional checks on line 158 of bbpress-functions.php
if ( bbp_use_wp_editor() && is_bbpress() ) {
Thanks @mudit-kumawat. I would add this, as admin users will still show the admin bar, so with your code we will have two divs with the same id:
// Add adminbar blank div to fix BBPRESS jQuery issue
function add_admin_bar_div() {
if( is_bbpress() && ! current_user_can('administrator') ){
echo '<div id="wpadminbar" style="display:none;"></div>';
}
}
add_action('wp_footer', 'add_admin_bar_div',15);
Thanks, so something like this:
// Actually build all of this HTML
function build_html() {
$this->sort_users();
$data = $this->stats_builder();
$HTMLOutput = "";
if (is_user_logged_in()) {
if ( is_bbpress() && current_user_can( 'spectate' ) ) {
foreach( $data as $key => $html ) {
$HTMLOutput .= "<div class='bbpas-" . $key . "' id='bbpas-" . $key . "'>" . $html . "</div>";
}
}
}
return $HTMLOutput;
}
Yes?
add an additional if statement
if ( is_bbpress() && ! current_user_can( 'spectate' ) )
if they can’t spectate then they are blocked
looked in pastebin.
I’m not sure what this function is there for, except possibly to speed up site display if they have not accessed the forum part ?
function dequeue_bbpress_style() {
if ( class_exists('bbPress') ) {
if ( ! is_bbpress() ) {
wp_dequeue_style('bbp-default');
wp_dequeue_style( 'bbp_private_replies_style');
wp_dequeue_script('bbpress-editor');
}
}
}
add_action( 'wp_enqueue_scripts', 'dequeue_bbpress_style', 99 );
it does tend to suggest that you have bbp_private_replies enabled ???
Hi All,
Is there a way to re-direct users that are logged in and land on the bbpress home location e.g /chat/ and re-direct them to a specific forum.
E.g, logged in users visits mysite.com/chat, and it redirects them to mysite.com/chat/forum/support.
i am using the code below found in the bbpress forums which re-directs guest to another page. It works great.
/**
* Redirect bbPress pages to registration page
*/
function kleo_page_template_redirect()
{
//if not logged in and on a bp page except registration or activation
if( ! is_user_logged_in() && is_bbpress() ) {
wp_redirect( home_url( '/register/' ) );
exit();
}
}
add_action( 'template_redirect', 'kleo_page_template_redirect' );
- Yes. W3TC with CSS minification.
- Yoast SEO. As far as I know, it doesn’t interact with CSS files.
- No.
- No.
Related change test: Tested with both screen
and all
. Did not work.
Additional information:
I have dequeued bbpress stylesheets for non-bbpress pages, using the below code.
function dequeue_bbpress_style() {
if ( class_exists('bbPress') ) {
if ( ! is_bbpress() ) {
wp_dequeue_style('bbp-default');
wp_dequeue_style( 'bbp_private_replies_style');
wp_dequeue_script('bbpress-editor');
}
}
}
add_action( 'wp_enqueue_scripts', 'dequeue_bbpress_style', 99 );
I hope this helps.
I also noted another issue where the replies were not loading (both topic replies and threaded replies) for any topics.
ok, for the participants trashing topics, install
bbp style pack
once activated go to
dashboard>settings>bbp style pack>Topic/Reply Display items 17,18,& 19
On the widgets, install
the ‘widget logic plugin’, and on pages you want the widget, use
is_bbpress()
in the condition
@robin-w
Thank you for the feedback.
It’s good that the issue is already addressed.
But the question is not about dequeuing, but about enqueuing.
Why not the bbPress core, enqueue the stylesheet only when is_bbpress()
is true?
with widget logic you can call ‘is_bbpress’ that will determine if you are in a forum page
Hi @pauldlb
Try this… Paste the follow code into function.php (Appearance – Editor – Functions.php)
/* Remove SideBar From bbPress Profiles and Topics*/
function disable_all_widgets( $sidebars_widgets ) {
if ( function_exists('is_bbpress') ) {
if (is_bbpress()) {
$sidebars_widgets = array(false);
remove_all_actions('bp_register_widgets');
unregister_sidebar( 'bp_core_widgets' );
}
}
return $sidebars_widgets;
}
add_filter('sidebars_widgets', 'disable_all_widgets', 1, 1);
Actually…. the solution above wasn’t going to work because if breadcrumbs are enabled and someone clicks on the “Forum Home”, we lose all the effort. However, I finally found the conditional statement that works.
This is only part of my code, but you can get the idea…I originally had this:
// For Jetpack Portfolio heading
elseif (is_post_type_archive()) :
echo '<h1 id="bts-page-title">' . __( 'WordPress Themes', 'bts' ) . '</h1>';
// For bbpress forum heading
elseif (is_bbpress('forum')) :
echo '<h1 id="bts-page-title">' . __( 'Support Forum', 'bts' ) . '</h1>';
However, when I did this, it worked:
// For bbpress forum heading
elseif (is_bbpress('forum') || is_post_type_archive('forum') ) :
echo '<h1 id="bts-page-title">' . __( 'Support Forum', 'bts' ) . '</h1>';
// For Jetpack Portfolio heading
elseif (is_post_type_archive()) :
echo '<h1 id="bts-page-title">' . __( 'WordPress Themes', 'bts' ) . '</h1>';
Now what is interesting, is that if I have the bbpress conditional “after” the Jetpack portfolio one, it would not work and the bbpress heading would be “WordPress Themes”. However, I had this sudden thought that perhaps there is a priority happening here, so I moved the bbpress conditional “before” the Jetpack one, and sure enough it works. The bbpress heading is “Support Forum” and the Jetpack portfolio is “WordPress Themes”.
Something about the sequence caused an issue…what and why I do not know.
Ah….found a fix for the above/last reply. I added the id of the page, so now the custom-bbpress.css only loads for bbpress and that page.
if (is_bbpress() || is_page( 209 ) ) :
Update: I had this in my functions:
if ( is_bbpress()) {
….etc.
But adding:
is_page()
Means that the custom-bbpress.css is going to load on all “pages”. A temporary solution, but not really the right solution.
Hopefully I got the right forum here.
I want to add a heading when on the “forums” archive home page of the bbpress forum. Right now I have this for jetpack’s portfolio…note this is just a snippet of my code:
if (is_post_type_archive()) :
echo '<h1 id="bts-page-title">' . __( 'WordPress Themes', 'bts' ) . '</h1>';
…but the bbpress forum header area is loading that title as well. I’ve tried so many variations and conditionals, none work. I did manage to get the “forum” titles to show for individual forums with:
elseif (is_bbpress('forum') ) :
echo '<h1 id="bts-page-title">' . __( 'Support Forum', 'bts' ) . '</h1>';
But does anyone have an idea how to get the conditional to show a custom header title for the bbpress home page?
As it’s above the title, then it’s before bbpress kicks in.
you could try
if (is_bbpress) {
echo 'hello' ;
}
but may not work
Or try to add something to your theme page.php or equivalent before the title
Something like (this won’t work it’s just to start you off!)
$array = (2925, 3567,4567) ;
if (in_array ($page_id, $array)) {
echo 'hello' ;
}
where 2925 etc are forum ID’s
Founded a workaround disabling yoast seo breadcrumbs in my theme files by using the conditional tag is_bbpress(). I will use the bbpress breadcrumbs in the forum pages.
Hello
I am using the latest version of WP and bbPress with iThemese Builder theme.
Through the theme functions I am able to show all parts of the forum on a particular theme layout, apart from the forum index page when the breadcrumb ‘forums’ link is clicked. This takes me back to the main template layout which does not have the forum wigdets as required on all forum pages.
I also have the same issue with the search results.
I have tried the following code but as I am not overly familiar with bbPress conditionals it does not solve the problem. I believe what I am look for is the correct information to go into this line:
if ( is_bbpress() && in_category( ‘page’ ) )
// create view for forums
function custom_filter_category_layouts( $layout_id ) {
if ( is_bbpress() && in_category( 'page' ) )
return '599b46ad5fa63';
return $layout_id;
}
add_filter( 'builder_filter_current_layout', 'custom_filter_category_layouts' );
Any advice appreciated.
Mike
I have two forums and I have two non-bbPress widgets. I’ve setup the widgets to show up on forum pages with the Widget Options plugin. Each of the forums need to show only the menu that pertains to it (match by state name). As of now, both widgets show up on both forum pages.
Tried conditional tag: is_bbpress() with the page ID’s, but it doesn’t change anything. None of my researched plugins seem to have this feature figured out.
Any ideas? Still fairly new to all this and not a coder so don’t have the best vernacular for troubleshooting.
WP version: 4.8.2
bbPress version: 2.5.14
Site: https://selfdirectforum.com/forum/
Hoping someone has solved for this…
I’m trying to make sure that all single topic pages are unique for SEO purposes. Currently, topics simply have the format “Forum – [Forum Name] – [Site Name]”. I want to prepend the topic so that the meta title tag format is “[Topic Name] – [Forum Name] – [Site Name]”.
I do not want to use Yoast or any other plugin, as this should be a pretty simple change.
The problem I am having is two fold:
1. In functions.php, I am unable to use anything like is_bbpress() or bbp_is_single_topic() to tell if I am on a specific page.
2. I am unable to get the bbPress topic title ahead of the pre_get_document_title() function so that I can prepend it into the meta header.
Any help would be greatly appreciated. This is for a WordPress/BuddyPress/bbPress integration.
Thanks in advance
sorry, missed that you were using wp tweaks which adds this sidebar. This plugin has no support, and doesn’t work with several themes by the look of it.
suggest you try
https://en-gb.wordpress.org/plugins/widget-logic/
the logic for forum pages is
is_bbpress()
for a widget to only show on forum pages
and to exclude from forum pages is
!is_bbpress()
Just to let you know that this issue was fixed by uninstalling the plugin “bbPress Login Register Links On Forum Topic Pages” and instead adding a login/logout link using the code provided here:
Layout and functionality – Examples you can use
and then adding code provided to make sure the links only appear in the forum and not the whole site:
change line 3 to
if ( is_user_logged_in() && is_bbpress() ) {
and line 6 to
elseif ( !is_user_logged_in() && is_bbpress() ) {
untested, but this should do it, come back if not
change line 3 to
if ( is_user_logged_in() && is_bbpress() ) {
and line 6 to
elseif ( !is_user_logged_in() && is_bbpress() ) {
Try this code. Put it on the function.php
/* Hide SideBar in bbPress Profiles and Topics*/
function disable_all_widgets( $sidebars_widgets ) {
if ( function_exists('is_bbpress') ) {
if (is_bbpress()) {
$sidebars_widgets = array(false);
remove_all_actions('bp_register_widgets');
unregister_sidebar( 'bp_core_widgets' );
}
}
return $sidebars_widgets;
}
add_filter('sidebars_widgets', 'disable_all_widgets', 1, 1);
You don’t say if You want the full-width to all pages or only to topics, forums, or profiles.
Regards,