Hello there,
I have a really strange problem… In the last few days I’ve noticed that all my messages do not show paragraphs, bolds, italics and neither links inside my topics.
I find it really strange and if you want to have a look to this is the link on a page where this happens. Inside this response there was some links and formatting but everything is gone.
It seems like WordPress is stripping out all the formatting my users add to the text and if you inspect the code you’ll find out that not a single <p> has been used…
I am using custom template pages but in order to test I’ve also renamed the bbpress/ folder inside my theme and the problem is still present. Tryed to use Twenty Fiftheen and the problem persists. Also checked the settings but everything seems normal.
The only thing I’ve done is update WordPress to the version 4.5, at least is the last action that I can recall.
Hope you can help me and thank you for your advices.
All the best,
Andrea
WordPress Version: 4.5
bbPress Version: 2.5.8
Genesis Version: 2.2.7
bbPress Genesis Extend Version: 1.1.1
Weirdly (considering how long ago this was posted), I recently had some updates trigger this same problem (the ‘in_array() expects parameter 2 to be array, null given in /abcde/htdocs/wp-content/plugins/bbpress/includes/common/functions.php on line 1199’ error, though in my case it’s actually line 1442). @korvinm’s solution is great but can be extended a bit so it won’t get overwritten by updates–instead of editing the file named by the error, go into your child theme’s functions.php file and add:
function LF_bbp_query_post_parent__in( $where, $object = '' ) {
global $wpdb, $wp;
// Noop if WP core supports this already
if ( in_array( 'post_parent__in', array($wp->private_query_vars ) ) )
return $where;
// Bail if no object passed
if ( empty( $object ) )
return $where;
// Only 1 post_parent so return $where
if ( is_numeric( $object->query_vars['post_parent'] ) )
return $where;
// Including specific post_parent's
if ( ! empty( $object->query_vars['post_parent__in'] ) ) {
$ids = implode( ',', wp_parse_id_list( $object->query_vars['post_parent__in'] ) );
$where .= " AND {$wpdb->posts}.post_parent IN ($ids)";
// Excluding specific post_parent's
} elseif ( ! empty( $object->query_vars['post_parent__not_in'] ) ) {
$ids = implode( ',', wp_parse_id_list( $object->query_vars['post_parent__not_in'] ) );
$where .= " AND {$wpdb->posts}.post_parent NOT IN ($ids)";
}
// Return possibly modified $where
return $where;
}
remove_filter('posts_where', 'bbp_query_post_parent__in', 10);
add_filter('posts_where', 'LF_bbp_query_post_parent__in', 10, 2);
This keeps the edit to the function in your child theme files so it won’t get overwritten, giving it a slightly modified name, then removes the filter’s callback to the bbPress function, and adds your modified one in its place. Just figured I’d share in case anybody else is still running into this issue and comes across this thread.
I’d like to create a forum index that resembles Flarum, where colour coded labels indicate which forum each topic belongs to.
bbPress conveniently outputs the names of each forum a topic is assigned to. Unfortunately, using just CSS, there is no way to assign different colours to each forum.
I’d like each different forum to have an ID selector, much like WordPress posts do, so that I could easily assign colour.
Example:
bbp-topic-started-in#forum-1 a {
background: green;
}
bbp-topic-started-in#forum-2 a {
background: yellow;
}
Could someone tell me, a) how I could accomplish this, or b) how I could present this for consideration in a future bbPress release?
hello! 🙂 first of all…
Forum Moderation
so what? the page is empty :/
i need to be able to set up a list of wp users to be the admin/moderators of the forum
i need to be able to make them know about a new post (i can do it via mailing list)
and they should be able to reply and make the question public via front end. and the op must be notified when someone replies to or publish the post.
it’s more of a Q and A system for everyone with moderation from a list of wp userd (doctors)
the only way i found to moderate incoming posts is a 2year old plugin with bulky backend system (it needs to be as easy as possible since the moderators wont be tech savvy guys)
is there any other solution?
thanks
Please find the code below.. I am sure it must be a very small error
add_action( 'rest_api_init', function() {
register_api_field( 'topic',
'post_parent',
array(
'get_callback' => 'slug_get_post_meta_cb',
//'update_callback' => 'slug_update_post_meta_cb',
'update_callback' => 'slug_update_spaceship2',
'schema' => null,
)
);
});
function slug_update_spaceship2( $value, $object, $field_name ) {
return update_post_meta( $object->ID, $field_name, $value);
}
function slug_get_post_meta_cb( $object, $field_name, $request ) {
return get_post_meta( $object['id'], $field_name );
}
That a nice project ! Any code you can share so we see what you try to do ?
Pascal.
code works fine for me to include topics posts and replies but same as above it shows private replies.
Hi,
I would say find the ‘content-single-forum.php’ file and edit it. You will probably see twice a line with <?php bbp_get_template_part( 'pagination', 'topics' ); ?> , so you need to delete the first one to hide the top pagination.
I didn’t test it, just guessing from what I read.
Pascal.
Hi,
[bbp-topic-form] is not working. I am able to use others shortcodes and they work fine but not the new topic form.
Please can someone tell me the cause this shortcode isn´t working?
i have added this code from gist.github.com/ntwb/7797990 but html tags appeared on website like
<!–more–>Go joging –> go jogging
<span style=”line-height: 1.5;”>It’s help me have a good job–>It helps me have a good job</span>
<!–more–>
anyone have solution ?
Thanks.
i have added this code from gist.github.com/ntwb/7797990 but html tags appeared on website like
<!–more–>Go joging –> go jogging
<span style=”line-height: 1.5;”>It’s help me have a good job–>It helps me have a good job</span>
<!–more–>
anyone have solution ?
Had a chance to test this out locally. The URL re-writes work like a charm, without any conflicts.
@siparker @netweb The plugin works almost perfectly, BUT there is still one big issue — by adding -postIDs to the end of Forum and Category URLs (mysite.com/forums/category-name-postIDstring) or (mysite.com/forums/category-name/forum-name-postIDstring), we’ve defeated the SEO purpose of re-writing these URLs.
For authority to be passed allll the way down to the topics, we need for the forums and categories’ permalinks to live without these -postIDs. That way, (mysite.com/forums/category-name/forum-name/topic-name-postIDstring) can get the full trickle down benefit from any links /category-name/ and /forum-name/ receive.
I’m going to play around with the plugin code to see if I can just rip the right bit out! Thanks again!
EDIT: So removing .'-f' .$post->ID from lines 50 and 60 fixed the URLs in the CMS BUT broke the page. It seems like the plugin relies on the postIDs to associate the new URLs with the old URL structure? If so, how can we achieve this without actually using the postID in the URL?
It’s actually much easier than this.
If you set words, phrases, or IP addresses in your Settings > Discussions of WordPress’s admin, bbPress will adhere. Whatever you use for WordPress comments, also works for bbPress topics & replies.
Hope that’s helpful!
Creators plugin All in One SEO Pack bug fixed. Have to wait on updates or:
In wp-content/plugins/all_in_one_seo_pack/admin/display/meta_import.php, change line 38 from
}else{
to
}elseif(!class_exists('bbPress')){
Great. My standard answer is always the same:
Check out the codex: https://codex.bbpress.org/layout-and-functionality-examples-you-can-use/#1-change-how-the-forum-list-displays
Or
Use a plugin like ‘bbP Toolkit’ or ‘bbp style pack’
Pascal.
If need be, I can make an account for you, so you can see what the issue is (as my forums are private).
Adding the following to functions.php in my theme-folder, did nothing:
if (!is_admin()) {
wp_deregister_script('jquery');
wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"), false, '1.11.3');
wp_enqueue_script('jquery');
}
I also restarted Apache, also to no avail.
Hello,
I have made this a little simple, where any visitor can have an overlay division hiding the topic content and everything when there are caught words in the currently viewing topic..
You can add this code to your theme’s functions file:
Remember: edit $list = 'test,bad topic,'; line to insert your watched words separated by commas without a space after the commas.
add_action('wp', function() {
/**
* Add the watched words or sentences separated by commas.
* Remember not to add a space before the words
* Example : 'evil dog,naughty cat,pig'
*/
$list = 'test,bad topic,';
// set up a global variable for our case
$GLOBALS['my_filtered_words'] = explode(',', $list);
});
add_action('bbp_theme_after_reply_content', function() {
if( ! get_the_ID() )
return;
$topic = get_post( get_the_ID() );
if( ! $topic || 'topic' !== $topic->post_type )
return;
global $my_filtered_words;
$words = preg_split( "/\s+/", $topic->post_content );
foreach( $words as $i => $word )
$words[$i] = strtolower($word);
$occurance = 0;
foreach( $my_filtered_words as $string ) {
$string = strtolower( $string );
$occurance += in_array( $string, $words ) ? 1 : 0;
}
if( ! ( $occurance > 0 ) )
return; // nothing caught
$cookie = isset( $_COOKIE['se_conf_warned_topics'] ) ? explode(',', $_COOKIE['se_conf_warned_topics']) : array();
if( in_array($topic->ID, $cookie) )
return; // confirmed before.
?>
<style type="text/css">
.se-conf-wt {position: fixed; top: 0; left: 0; background: rgba(0, 0, 0, 0.78); width: 100%; height: 100%; z-index: 999;}
.se-conf-wt p {color: #fff; position: relative; top: 50%; display: table;margin: 0 auto;}
.se-conf-wt a {color:#fff;}
</style>
<div class="se-conf-wt t-<?php echo $topic->ID; ?>">
<p>This topic contains offensive content. <a href="javascript:;">Continue?</a></p>
</div>
<script type="text/javascript">
window.onload = function() {
var a = document.querySelector('.se-conf-wt.t-<?php echo $topic->ID; ?> a'),
b = document.body;
a.onclick = function() {
var expires = new Date(),
cval = '<?php echo isset($_COOKIE['se_conf_warned_topics']) ? $_COOKIE['se_conf_warned_topics'] : ''; ?>';
expires.setMonth(expires.getMonth() + 6); // 6 months expiracy date
cval += '<?php echo $topic->ID; ?>,';
document.cookie = "se_conf_warned_topics=" + cval + "; expires=" + expires;
// cookie set, now let's hide the warning
this.parentNode.parentNode.remove();
b.style.overflowY = '';
return false;
}
b.style.overflowY = 'hidden';
}
</script>
<?php
});
Tested on my local installation and it works fine.
Let me know how it goes.
Samuel
Hello, here are the steps for you:
1. Create a ‘new topic’ page at example.com/new-topic/ and add [bbp-topic-form] shortcode as content.
2. Add this code to your child theme’s functions file:
add_filter('the_content', function($content) {
global $post;
if( 'post' == $post->post_type && is_user_logged_in() ) {
$content .= '<p><a href="' . home_url('new-topic/?se_pid=' . $post->ID) . '">Generate a topic</a></p>';
}
return $content;
});
add_action('init', function() {
$content = null;
if( isset( $_GET['se_pid'] ) ) {
$pid = (int) $_GET['se_pid'];
$content = get_post( $pid );
}
$GLOBALS['se_post'] = $content;
});
add_filter('bbp_get_form_topic_title', function( $title ) {
global $se_post;
if( $se_post ) {
return $se_post->post_title;
}
return $title;
});
add_filter('bbp_get_form_topic_content', function( $body ) {
global $se_post;
if( $se_post ) {
return $se_post->post_content;
}
return $body;
});
Test it out, go to your posts and scroll down to the bottom, click the “generate ..” link and see if it worked.
I am here for any further customization or if you encounter issues with implementing this.
Regars,
Samuel
Hi there
Thanks for the reply.
For the one or two lines of code that needs to be removed from the bbpress plugin files it doesn’t seem right to go to all the effort of a child theme.
I can always remove the code each time the plugins updated.
Would you happen to know where it is and which line I need to remove.
Thanks
Hi,
I suppose with ‘core’ you mean the bbPress plugin code ? NO, NEVER ! You don’t want to loose your changes at the next bbPress update, right ?
I think @robkk answer was the most appropriate one for this topic: Just work on the template, copy it to your (child)theme and modify as he indicated.
See probably step 5 and 6 from https://codex.bbpress.org/themes/theme-compatibility/step-by-step-guide-to-creating-a-custom-bbpress-theme/ an also https://codex.bbpress.org/functions-files-and-child-themes-explained/
Pascal.
Something seems very strange to me, all your links on your site have a // in front of them.
So the login form has <form method=”post” action=”//http://www.barabajen.se/wp-login.php” class=”bbp-login-form”>
Please try to fix that first (no idea where it comes from, but for sure it’s not bbPress.
Pascal.
When i try to log in to BBpress on my site either by the bbpress-widget or with the[bbp-login] shortcode all I get is a blankscreen and nothing more happens. Everthing just stops with a blank screen on …/wp-login.php.
I looked around and couldnt really find an answer to my problem.
My site: http://www.barabajen.se, And there is a shortcode in the bottom or the right widget-area
Thanks in advance.
Thank you all for your feedback. After some thorough investigation, I managed to finally configure my caching so that it actually works (never checked that… my mistake – I entered the wrong path in .htaccess). Also, I hard-coded some tweak in my theme, something which was only recently brought to my attention.
And this morning, one of our users finally had site load times of <1s on our forums. I can happily leave them on our main site – even if P3 reported bbpress & Associates as major sources of site load time: That it still is very little with good caching and static CSS/JS files in place (which I did not have before, they were computed on site load, thanks to my theme).
Best
Manuel
OK, now I see !
How about [bbp-lost-pass] ?
Check out https://codex.bbpress.org/features/shortcodes/
Pascal.