I am working on a theme and need to deque all bbpress scripts and enque my own if I am on forum pages. This is what I used to start with
if( !is_admin() ){
/**
* Replace bbpress style with our own
* @internal
*/
function _thz_action_bbpress_style() {
wp_dequeue_style( 'bbp-default' );
if (is_bbpress()){
wp_enqueue_style( THEME_NAME. '-bbpress' );
}
}
if (function_exists('is_bbpress')){
add_action( 'wp_enqueue_scripts', '_thz_action_bbpress_style' );
}
}
issue with this is that is_bbpress() is not recognized on pages that use any bbpress shortcodes like
[bbp-forum-index]
Can someone please provide a working conditional that runs only on forum pages and not throughout the whole site. Thnx!
This is the bbpress.php file that you would need and its required code.
https://gist.github.com/robkk/a89e6cff104f70556f52c6df3f6b69b0
This is the custom CSS you will need.
.bbpress .main-inner,
.bbpress .main {
background: none !important;
padding-right: 0 !important;
padding-left: 0 !important;
}
This will not work for pages with bbPress shortcodes though.
But you can work around that since most shortcodes are supposed to be placed in pages, you can create another template just for full width layouts in your theme. You can use this whenever you create a new page and select the template to use for your page.
To create a full-width template, you can literally just copy the bbpress.php file I created for you, rename it to full-width.php, put it in your child theme, now you need to edit the file and place
<?php
/*
Template Name: Full-Width
*/
?>
right above
<?php get_header(); ?>
You will need more custom css for any page using this template in your theme and it should be
.page-template-full-width .main-inner,
.page-template-full-width .main {
background: none !important;
padding-right: 0 !important;
padding-left: 0 !important;
}
If you plan to use both, just combine the two custom CSS statements, and now you should be good to go.
suspect its a wordpress issue since I am calling a wp function
if you can’t upgrade to 4.5.2, come back and I’ll take a guess at some retrospective code!
loop-forums.php is a file that sites on your server, you cannot ‘call it’ from within php.
You access the file using FTP and an editor.
see ‘What is FTP and how do I access it?’ within this link
https://codex.bbpress.org/functions-files-and-child-themes-explained/
The following CSS works to resolve issues .2 and .3 above:
#bbpress-forums .bbp-forums-list {border:none; color:#INSERTHEXCOLOROFYOURLINKS;}
I am still hopeful to receive some input on 1. .4 and .5 and the best practice question.
Kind Regards
Max
I didn’t fix it, it’s just the page I created(using the short code), that I thought would hold the Forums. But apparently it just holds the first page, then once you click something it redirects to the injected instance of the Forums inside of the default Page, with the standard sidebar formatting. This is indicative of the way Hueman theme allows the bbpress forums to work. It works within the Global framework only, and won’t let me keep it on a Page I create. At least that’s the way it appears to be working, and I have seen other posts with the exact same issue, but it seemed everybody eventually had a different way to resolve it. I can’t seem to get anything to work.
@aaronbennett2097 sounds like you want something like this?
function rkk_topic_description() {
$excerpt = bbp_get_topic_excerpt();
echo '<div style="text-align:left"><p>'.$excerpt.'</p></div>';
}
add_action('bbp_theme_after_topic_title','rkk_topic_description');
Hey Robin
I installed your snippet as follows:
// Filter wp_nav_menu() to add profile link
add_filter( 'wp_nav_menu_items', 'my_nav_menu_profile_link' );
function my_nav_menu_profile_link($menu) {
if (!is_user_logged_in())
return $menu;
else
$current_user = wp_get_current_user();
$user=$current_user->user_login ;
$profilelink = '<li><a href="http://www.mysite.com/forums/users/' . $user . '/edit">My Profile/Edit Profile</a></li>';
$menu = $menu . $profilelink;
return $menu;
}
It works perfectly for front end users, however if I am already logged in as the admin and then click on the My Profile link created by your snippet, rather than being redirected to my profile page, I get the “Oops! That page can’t be found” message. The URL that appears in my browser appears correct:
http://localhost/forum/forums/users/MYUSERNAME/edit
Any assistance you can provide is greatly appreciated.
Kind Regards
Max
SOLUTION!
REMOVED:
add_filter( 'bbp_get_reply_content', array( $this, "shortcode_whitelist" ) );
FROM PLUGIN:
bbPress Advanced Statistics, file: class-bbpress-advanced-statistics-extras.php
CAUSE:
Breaks the loading of shortcodes.
I’m hopeful this will help someone else. It seemed to be a problem with the bbPress Advanced Statistics plugin.
UPDATE 3:
return apply_filters( 'bbp_get_reply_content', $content, $reply_id );
in bbpress/includes/replies/template.php
This code breaks the entire shortcode loading function.
If I patch this to say return $content; it will start working.
Now to see why this happened..
It seems to me that this is the problematic code:
in content-single-topic.php
<?php if ( bbp_has_replies() ) : ?>
<?php bbp_get_template_part( 'pagination', 'replies' ); ?>
<?php bbp_get_template_part( 'loop', 'replies' ); ?>
<?php bbp_get_template_part( 'pagination', 'replies' ); ?>
<?php endif; ?>
If I remove this code block, all of the shortcodes start working.
UPDATE 1:
More specifically, this is the exact row that the problem appears at:
<?php bbp_get_template_part( 'loop', 'replies' ); ?>
UPDATE 2:
I followed the problem down to..
in file loop-single-reply.php
<?php bbp_reply_content(); ?>
If I remove this line, the shortcodes starts magically working.
Hello,
We have a problem on our site with loading shortcodes on /topic/ pages, as you can see in the link below:
http://www.futsverige.se/forums/topic/test/
However, the shortcodes work everywhere else. So the problem seems to be within bbPress suppressing the do_shortcode() calls from the theme.
Anyone knows what could cause this or point us in the right direction on how to circumvent it?
Thanks
was kinda hoping you could say what ‘buggy’ means.
I suspect that both plugins modify some common pieces of code, so may ‘overwrite’ each other in places.
Knowing where these places were would help immensely in fixing them for others.
@khunmax WordPress has smilies and emoji included in it, but if you need a plugin to customize the images used for each text smiley :) or full text output :smile: , then use WP-MonaLisa. So as long as you just use custom images for the default full text and smiley text to output some custom smilies and images, it will fallback to the normal WP emoji, any custom ones will not fall back.
https://codex.wordpress.org/Using_Smilies
https://codex.wordpress.org/Emoji
In the future you might need to use a search and replace plugin to revsolve any custom smiley outputs that might just output something like :custom_smiley:
:) 🙂
Please excuse the length of this post. It seeks information regarding functionality and best practice.
FUNCTIONALITY
I have developed my own functionality plugin for BBpress and would be very grateful if some one could provide me with the functions snippets for the following features:
1. Creating a header and footer for each individual forum in the index list (ala Style kit template option)
2. Removing the vertical bar that appears to the left of the sub-forum list when the following code is used:
#bbpress-forums .bbp-forums-list li {display: list-item !important;}
3. Removing the commas that appear in the vertical list of the subforums. This looks odd and ugly. My links are style in orange and then at the end of each subforum there is a black comma. Can this comma be removed or can it be styled with css so that its color is the same as the subforum links? If it can be styled what is its unique selector?
4. The BBP toolkit has an option to remove all of the blue and yellow alert/info boxes. What is the snippet for this function?
5. The BBp toolkit has an option to only add css to BBP pages. What is the snippet for this function and is it necessary(or a possible conflict) if I chose to run WP minify?
BEST PRACTICE
This is the first site I have developed with a forum. What is the best practice regarding admin forum content, forum rules is a relevant example. Should I create a forum dedicated to my admin topics (included form rules), or rather, should I just create topics for admin content and make them super sticky (which I understand means they will appear at the top of every forum)
Again my humble apologies for the length of this post. And, as always, thanks very much for anyone render their valuable assistance.
Kind Regards
Max
With Robin’s valuable assistance I now have a created new topic link at the top of each of my forums.
However one forum is for my use solely and only contains locked topics such as forum rules.
1. Is there a snippet of code that I can add to my functionality plugin that allows me to selectively remove the create new topic link from atop a specific forum?
2. And,or, can the create new topic link just be hidden using CSS visibility:hidden, and if so what is the link’s unique selector?
Thanks in advance for any assistance provided.
Kind Regards
Max
1.
//This function changes the heading "Freshness"
function rew_change_translate_text( $translated_text ) {
if ( $translated_text == 'Freshness' ) {
$translated_text = 'hello' ; }
return $translated_text;
}
add_filter( 'gettext', 'rew_change_translate_text', 20 );
2.
function rew_create_new_topica () {
$text= 'Create New Topic' ;
if ( bbp_current_user_can_access_create_topic_form() && !bbp_is_forum_category() ) echo '<div style="text-align: center;"> <a href ="#topic">'.$text.'</a></div>' ;
}
function rew_create_new_topicb () {
echo '<a name="topic"></a>' ;
}
add_action ( 'bbp_template_before_single_forum', 'rew_create_new_topica' ) ;
add_action( 'bbp_theme_before_topic_form', 'rew_create_new_topicb' ) ;
There were features in both the BBp Style Pack and BBpress Toolkit that I desired.
Unfortunately when ever I installed both plugins, my site became buggy. There is a conflict between the two it would seem.
So I bit the bullet and created my own functionality plugin and used it and WP Custom CSS to create each of the features and styling I desired from the Style Pack and the Toolkit.
There are just three features that I couldn’t find any documentation for:
1. Changing the header label Freshness to other wording, and
2. Creating a “create new topic” link.
I am aware that the first of these features is also included in Robins other plugin called Latest Post (or something like that) however that plugin also includes another feature that I do not require (as I have coded my own)
And so my request. Can someone please provide me with:
1. a function snippet to change freshness to other wording
2. a function snippet to add a “create new topic” link at the top of a forum
Thanks in advance for any assistance.
Kind Regards
Max
Hi,
I am using the code
<div class=”bbp-forum-last-topic-name”>” title=”<?php bbp_forum_last_topic_title(); ?>”>
<?php bbp_forum_last_topic_title(); ?></div>
<p></p><?php bbp_forum_last_active_time(); ?>
But i would like to replace the last topic link, with a link to the reply, i have tried bbp_forum_last_Reply_permalink but it just links to the reply only, and not inside the topic.
Hi – on mylogin page in which I’m using the bbpress shortcode to generate the login box, when someone enters the wrong username or password they are redirected to the admin wordpress login. Not only do I not want it to be redirected there, that does make the site secure at all. Can you please advise on how to prevent this from happening so user is never sent to the wp admin login? thank you.
So, really, I have a two-part question. First, I’d like to add some new roles. I’ve read and looked all over the place without any real answer. I know what codes to use per the documentation. That said, I’m not sure which file to place them in and that’s the part I can’t find definitive answers on. If someone could direct me which directory and file to add it to that’d be great. I already know not to do it to the BBpress core files.
Also, is there a way to assign specific moderators to specific boards. Say a user is a moderator, but I don’t want them to moderate all boards, just specific boards. Is that possible?
Hello Robkk,
I tried the moderation plugin you suggested but it has not been updated in over 3 years so it does not work for me.
I read here https://codex.bbpress.org/moderation-and-blacklisting/ that discussion settings should be applied for bbpress but that also does not work.
For whatever reason anyone can immediately post replies without having to wait for moderation.
Under Settings > Discussion > Before a comment appears – I have the checkbox selected for “Comment must be manually approved” however that does not happen.
Thanks,
Dustin
I’m trying to import a phpbb forum with about 50,000 posts into a local dev site.
It continually stalls at “Converting topics (4900-4999)”
I’m trying to follow the instructions here:
Import Troubleshooting
which say to make a copy of the db and drop all records except within the offending range and try the import again to isolate the problematic row.
Should I go into phpbb_topics or phpbb_topics_posted to try and look for the offending problem?
Once I have the right table, do I then delete the first 4899 rows that appear in the db?
I’m using the latest WordPress and have tried both bbpress 2.5.9 and 2.6alpha.
Thanks for any help you can give me.
It’s important that BuddyPress/bbPress is capable of protecting itself first before resorting to other 3rd-party/premium plugins.
It is important, and bbPress does protect itself, where appropriate. The forums at this link are public forums, which means that anyone can view them, logged in or not. The MemeberPress plugin is restricting these public forums to logged in users. Since it’s a premium plugin, I don’t have access to the code. My guess, since it seems to do it’s job well on the forums, is that it’s not properly applying the same logic to single topics/replies and search. The result being that there is some data leakage.