Hello
I am seeking help with the correct conditionals to show a custom view.
I am using
WP Version 4.8.2
bbPress Version 2.5.14
Ithemes Air Theme
I have been given the following code to insert into the functions.php file in my child theme but I am missing something here?
function custom_filter_category_layouts( $layout_id ) {
if ( is_single() && in_category( 'news' ) )
return 'INSERT LAYOUT NUMBER';
return $layout_id;
}
add_filter( 'builder_filter_current_layout', 'custom_filter_category_layouts' );
I have tried most of what look to be the relevant conditionals at https://codex.bbpress.org/bbpress-conditional-tags/
I can get most forum views to use a theme layout I have created in Air Theme apart from the forum index page and the CHILD FORUMS (forums created with a parent)
I spoke with iThemes support and they told me it was best to ask here. If someone could help me out here it would be appreciated.
Best Regards
Mike
This is the first post I’ve found that accurately describes my predicament.
I am setting up a development site and attempting to import my forums via multiple XML files. However, the import process seems to be breaking a key relationship that allows the front-end of BBPress to work.
After importing, the Forums, Topics, and Replies all display correctly in the Dashboard, but on the front end I just get the standard “Oh bother! No topics were found here!” If I then run the Repair Tools “Recalculate the parent topic for each post” and/or “Recalculate the parent forum for each post,” then the relationship between Forums and Topics is lost, and the Replies page fails to load completely (returns an empty page with no error message).
From my digging around in the database, this problem seems centered around the field post_parent in wp_posts. On import, WordPress is setting this to “0” instead of the value in my XML file. If I click “Edit” on a Topic in the Dashboard and then click “Update” without changing anything, WordPress correctly repopulates this post_parent value and the Topic appears on the front end under its parent forum. But like @bigt11 and @welshdemon, I don’t have time to do that with 1,200 Topics and 7,400 Replies.
Does anyone have any ideas? I have spent weeks trying to figure this out. I have tried multiple different XML import plugins, but none of them seem to word well with BBPress (or work with big XML files). Any help you can give here is very much appreciated!
The steps have been outlined at this link and it works perfectly.
Shortcode to add “Edit Profile” link
Can anyone help me Style this Recent topic widget to match what I currently have on my page for Recent Posts.. I would like it to use the Avatar of the user that posted like it does now, just bigger and have it look the same..
http://piw.ewarena.com/ is the webpage
Ive messed with the output code a little and always mess it up cant get it to how I want since im a newbie to the CSS stuff.. Any help would be appreciated!
using the BBpress Recent Topic Widget..
Relevant tag validation code for above since I had to write it for my project anyways:
function new_reply_pre_set_terms_tag_test($terms, $topic_id, $reply_id)
{
//Bail Early if not set
if(!$terms)
return $terms;
//Bail early if we are allowed to modify tags
if(current_user_can( 'modify_topic_tags' ))
return $terms;
if(!is_array($terms))
$terms = explode(', ', $terms);
//For each to check if array term already exists. Remove if doesnt
foreach ($terms as $tag => $tag_value):
if(!term_exists($tag_value, 'topic-tag')):
unset($terms[$tag]);
endif;
endforeach;
return implode(', ', $terms);
}
function new_topic_pre_insert_tag_test($data)
{
//Bail Early
if(!is_array($data) || !isset($data['tax_input']) || !isset($data['tax_input']['topic-tag']))
return $data;
//Bail early if we are allowed to modify tags
if(current_user_can( 'modify_topic_tags' ))
return $data;
//Make sure we're an array
if(!is_array($data['tax_input']['topic-tag']))
$data['tax_input']['topic-tag'] = array($data['tax_input']['topic-tag']);
//For each to check if array term already exists. Remove if doesnt
foreach ($data['tax_input']['topic-tag'] as $tag => $tag_value):
if(!term_exists($tag_value, 'topic-tag')):
unset($data['tax_input']['topic-tag'][$tag]);
endif;
endforeach;
return $data;
}
add_filter('bbp_new_reply_pre_set_terms','new_reply_pre_set_terms_tag_test', 22, 3);
add_filter('bbp_edit_reply_pre_set_terms','new_reply_pre_set_terms_tag_test', 22, 3);
add_filter('bbp_new_topic_pre_insert','new_topic_pre_insert_tag_test');
The reason the function doesn’t work is because BBPress throws a fatal error when it tries to handle the array of items when it expects it as a string. We probably just need to get a filter in the core that allows us to manipulate that value before it tries to use the split() function.
Until then, kind of a hacky workaround is to use JS to append the values to a hidden field:
function display_tag_elements($selectedTags, $userRole, $task)
{
$html = array();
$tags = get_categories(array('hide_empty' => 0, 'taxonomy' => 'topic-tag'));
$selectedTagsArray = explode(', ', $selectedTags);
if ($userRole != 'bbp_participant' || $task != 'edit')
{
$html[] = "";
foreach ($tags as $tag)
{
$selected = '';
if (in_array($tag->name, $selectedTagsArray))
{
$selected = 'checked';
}
$html[] = "<input type='checkbox' class='bbp_topic_tags_checkbox' name='bbp_topic_tags_checkbox[]'" . $selected . " value='" . $tag->name . "'>" . $tag->name . " ";
}
$html[] = "<input type='hidden' class='bbp_topic_tags_hidden' name='bbp_topic_tags' value='".$selectedTags."'>";
$html[] = "
<script>
var checkboxes = document.getElementsByClassName('bbp_topic_tags_checkbox');
var hidden = document.getElementsByClassName('bbp_topic_tags_hidden');
var hiddenVal = hidden[0].value.split(', ');
for(var x = 0; x < checkboxes.length; x++)
{
checkboxes[x].addEventListener( 'change', function()
{
var index = hiddenVal.indexOf(this.value);
var checked = this.checked;
if(checked && !index > -1)
hiddenVal.push(this.value);
else if (!checked && index > -1)
hiddenVal.splice(index, 1);
hidden[0].value = hiddenVal.join();
});
}
</script>
";
} else
{
$html[] = $selectedTags;
}
return implode('', $html);
}
However this has a pretty notable downside in that someone could just inspect the code and add whatever they want to the hidden field. So you’ll want to make sure your also using one of the spam filters like bbp_new_reply_pre_set_terms to make sure the new values are terms you’ve predefined.
Side note: there also seems to be a pretty annoying bug in that participants can edit the topics tags on reply, so I would just disable it on reply for non-moderators.
EDIT: kind of like I just did. I don’t think I should be allowed to add tags to existing topics. this feels like a bug.
Anybody knows a code to insert for having quote?
Hi LeGuerg,
Thanks for the useful post. I have added those lines of code in two php files that you mentioned, but still particants can’t delete their own posts.
/home/XXX/public_html/XXX/wp-content/plugins/bbpress/includes/replies/capabilities.php
/home/XXX/public_html/XXX/wp-content/plugins/bbpress/includes/topics/capabilities.php
Any idea why? Anyone’s help will help will be greatly appreciated.
I’m having this problem after trying this solution, searching the codex and this forum. Here are all the various solutions I’ve tried:
.reply {
color: #000000 !important;
}
#commentform #submit, .reply, #reply-title small {
background-color: #000000;
color: #ffffff;
}
.forum a { color: black !important; }
.bbp-forum-info { color: black !important; }
.bbp-forum-topic-count { color: black !important; }
.bbp-forum-reply-count { color: black !important; }
.bbp-forum-freshness { color: black !important; }
.bbp-topics {
color: black !important;
background-color:white;
}
.bbp-forums a { color: black !important; }
#bbpress-forums div.bbp-topic-content a,
#bbpress-forums div.bbp-reply-content a {
background-color: white;
}
#bbpress-forums div.even,
#bbpress-forums ul.even {
background-color: #fff;
}
#bbpress-forums div.odd,
#bbpress-forums ul.odd {
background-color: #fbfbfb;
}
/*styling to move 'Subscribe' to right hand side */
.single-forum .subscription-toggle {
float:right !important ;
}
I would like to add the Recent Topic Widget to the Footer of my page, however it does not match the format.. I have opened the widget.php file and found it but keep getting stuck on the code.. Any ideas/help?
Below is the link.. I would like the recent topics to match the recent posts part of the footer..
http://piw.ewarena.com/2017/10/another-news-test/
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/
Hi Gunilla,
If you have still not resolved your problem, you need to edit your wp-config.php file which should be located in the root of your WordPress installation. You need to insert below mention code at the end of the file and then this error will disappear.
define( โWP_MEMORY_LIMITโ, โ256Mโ );
Source: https://www.webxen.com/kb/wordpress-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted/
I have a plugin called myCred which allows me to add a shortcode to a post so that anyone looking at that post will be allowed to click on a link to add points.
I am trying to figure out where in bbPress I will add this shortcode so that the link will appear for each post.
I am guessing that I will need to create a specially named page and then add the shortcode, but I am not sure about how to create the page (i.e. what name to give it). Am I on the right track, and if not, can someone help?
Hi everyone,
I have almost finished setting up BBpress on my site. The last thing I am stuck is I want to add WP Social Login ICONS to the bottom of topic discussions. I have already succeeded adding this to bottom of forums here https://ehospital.in/forum/help-support/about-us/ by adding the php code<?php do_action( 'wordpress_social_login' ); ?>
I want to do the same to the bottom or under the user not logged in template notice. But unable to do that. Most probably, I am adding the code to wrong templates? Please tell which template should I edit?
Thanks for finding the solution. Where do I add the code for menu and forum to make the Profile show up in Menu?
I’m trying to integrate buddypress-docs with bbpress forums; the intention is to have topics of discussion within an article/doc. Using buddypress-docs hook ‘bp_docs_after_doc_content’, I create a corresponding forum (if it doesn’t exist) and add a shortcode to display a topic creation form. If a topic exists and is selected, I redirect to the associated article, and display a single topic with:
echo do_shortcode( '[bbp-single-topic id=' . $topic_id .']' );
So far, so good, I don’t know if it is the right aproach, but it seems to work.
The problem comes when I want to post a reply within the selected topic. $_REQUEST variables are used to detect and display the selected topic, but on single-topic the additional ‘bbp_redirect_to’ hidden field is added, causing to redirect and lose those variables. I commented the line where this field is added (bbpress/includes/common/template.php:1620) and it works the way I want, but don’t want to do that ๐
Any suggestions on how to work this around without messing around with the plugin’s code? Hope the issue is clear, thank you for any help you can provide and for taking the time to read this.
Wordpress ver. 4.8.2
BBPress ver. 2.5.14
BuddyPress Docs ver. 1.9.4
Found solution ๐
I just added <?php bbp_form_topic_tags(); ?>to the input vvalue, so now it look’s like thisL:
<input type="text" value="<?php bbp_form_topic_tags(); ?>" />
Regards
Hi
When I editing some topic I don’t see tags in the input which I entered, can we call them via some PHP code?
Also screenshot: http://prntscr.com/gvpn8k
Best Regards, and also I want to say that I like minimalism of this plugin ๐
Regards
I donโt want to change the colour using code as none of our participants would be able to do that
The changes made in the CSS, are global and participants will not have to add any CSS code. Once the changes are applied they are visible to everyone across the website.
Not sure why its not working, seems to work on my end.
I believe the cause of the issue is the wordpress theme your website is using.
The best solution would be to contact the authors of the theme WPZOOM, and im sure they can find a quick solution.
If not, you could try adding the CSS once more, the following should work:
#bbpress-forums div.bbp-topic-content p a, #bbpress-forums div.bbp-reply-content p a{
background: none;
color: black !important;
position:relative !important;
display:inline-block !important;
visibility: visible !important;
}
In truth it is difficult to address any styling issues without being able to see the website, if you can not get in touch with the authors of the theme I could try my best to find a solution.
Thanks @mithrandir786 there are no plugins to alter the appearance of bbPress. And the CSS didn’t work. What else can I try? I don’t want to change the colour using code as none of our participants would be able to do that. Unless there is a visual editor?
Thanks,
Jan
Appears to be a css issue, are you using any plugins to modify the appearance of bbPress ?
The following css should fix this
.bbp-body .hentry p a{
color:#3f3f3f !important;
}
you could change the color for the link to one of your preference by modifying the color property.
If you are using wordpress version 4.7 and above, To add the css, in the WordPress dashboard navigate to:
Appearance>customize>Additional css
copy and paste the code and save changes.
Found another plugin
<?php
/*
Plugin Name: .html in url
Plugin URI: http://www.witsolution.in/
Description: Adds .html to pages.
Author: witsolution
Version: 1.0
Author URI: http://www.witsolution.in/
*/
add_action('init', 'witsolution_page_permalink', -1);
register_activation_hook(__FILE__, 'witsolution_active');
register_deactivation_hook(__FILE__, 'witsolution_deactive');
function witsolution_page_permalink() {
global $wp_rewrite;
if ( !strpos($wp_rewrite->get_page_permastruct(), '.html')){
$wp_rewrite->page_structure = $wp_rewrite->page_structure . '.html';
}
}
add_filter('user_trailingslashit', 'witsolution_page_slash',66,2);
function witsolution_page_slash($string, $type){
global $wp_rewrite;
if ($wp_rewrite->using_permalinks() && $wp_rewrite->use_trailing_slashes==true && $type == 'page'){
return untrailingslashit($string);
}else{
return $string;
}
}
function witsolution_active() {
global $wp_rewrite;
if ( !strpos($wp_rewrite->get_page_permastruct(), '.html')){
$wp_rewrite->page_structure = $wp_rewrite->page_structure . '.html';
}
$wp_rewrite->flush_rules();
}
function witsolution_deactive() {
global $wp_rewrite;
$wp_rewrite->page_structure = str_replace(".html","",$wp_rewrite->page_structure);
$wp_rewrite->flush_rules();
}
?>
for posts and pages its working fine. How to make it work for topic and forums for BbPRESS?
@robin-w, @johnjamesjacoby
Thankyou very much for replying,
I am currently working on a solution, That was my initial observation aswell, regarding hard coded values. Users will be able to opt-in or opt-out by submitting a checkbox input field. I was hoping I could post back soon, once I had accomplished a (not so embarrassing) solution.
Thanking you again for your help, and for all your exceptionally amazing work with bbPress.
Yes that would be the best solution, depending on their support for theme customization. I have extracted(just for testing purposes) the CSS from there live demo site for ‘discoverypro’, and can confirm it is the cause of the bbPress styling issues.
Users names from under their profile pictures trail off the right side of the screens
fix:
.bbp-body .bbp-topic-meta .bbp-author-name{
display:block;
}
when reading posts and replies within topics, all the users profile pics squash themselves all together at the top left hand-side of the screen.
*I cannot recreate this issue as it is specific to your website, however if you could provide a link to your forums/website it would be possible to fix the issue.