Further study of the code showed that works for all addresses where /users/.
It closes the profile / forums / users / name /
And doesn’t work for / forums / users / name / replies /
This function will take all attempts to go to the replies page to whatever url you want
add_action( 'bbp_template_redirect', 'neon_check_replies');
function neon_check_replies(){
//only execute if the url contains both /users/ and /replies/, so test for this first
if (strpos($_SERVER['REQUEST_URI'], '/users/') == FALSE && strpos($_SERVER['REQUEST_URI'], '/replies/') == FALSE) return ;
else wp_redirect( 'https://example.com/some/page' );
}
Put this in your child theme’s function file –
ie wp-content/themes/%your-theme-name%/functions.php
where %your-theme-name% is the name of your theme
or use
Code Snippets
ok, so using this process for each of the following files in place of xxfilexx.php below
find
wp-content/plugins/bbpress/templates/default/bbpress/xxfilexx.php
transfer this to your pc and edit
and save
create a directory on your theme called ‘bbpress’
ie wp-content/themes/%your-theme-name%/bbpress
where %your-theme-name% is the name of your theme
Then transfer the file you saved above and put in in the directory called bbpress that you created above, so you end up with
wp-content/themes/%your-theme-name%/bbpress/xxfilexx.php
bbPress will now use this template instead of the original
so template 1.
\templates\default\bbpress\user-profile.php
to remove lines 42 & 43 to tale out the counts if you wish.
then template 2
templates\default\bbpress\user-details.php
take out lines 34-60
then templates
\templates\default\bbpress\user-topics-created.php
\templates\default\bbpress\user-replies-created.php
take out all the code between the 2 ‘do_action’ lines
That should get you there
ok, so you say you get an error
Error thrown
Call to a member function get_users_for_object() on null
is this the entire error, or is there more?
when does this occur eg on every website page, on bbpress pages, on particular pages ?
It is so long ago since I used it. I am not sure which theme you are using – it really depends on that. I was using the old Responsive theme and @robkk advised me to use a different code for the bbpress.php file. I am coying what I found in my files for you here, but I really don’t know if this is the correct one. Unfortunately, @robkk is not active any more – he was truly wonderful.
<?php
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) {
exit;
}
/**
* bbPress Template
*
*
* @file bbpress.php
* @package bbPress
* @author Robkk
* @version Release: 1.0
* @filesource wp-content/themes/responsive/bbpress.php
* @link https://codex.bbpress.org/themes/theme-compatibility/getting-started-in-modifying-the-main-bbpress-template/
* @since available since Release 2.4
*/
get_header(); ?>
<div id="content-full" class="grid col-940">
<?php if ( have_posts() ) : ?>
<?php while( have_posts() ) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h1 class="entry-title post-title"><?php the_title(); ?></h1>
<div class="post-entry">
<?php the_content(); ?>
</div>
<!-- end of .post-entry -->
<div class="post-edit"><?php edit_post_link( __( 'Edit', 'responsive' ) ); ?></div>
</div><!-- end of #post-<?php the_ID(); ?> -->
<?php endwhile; ?>
<?php endif; ?>
</div><!-- end of #content-full -->
<?php get_footer(); ?>
Recently my MYSQL CPU usage went from 40% to over 100% and my server has been slowing down as a result. In doing some research I’ve learned to setup some mysql logging for slow queries. I have a particular query that happens often. In the query below it appears that over 700,000 rows are queried in the DB taking up almost 3 seconds. Imagine that times however many users and it is bogging the site down. Is this query below from bbpress or how can I tell? It’s hard to trace where it is being called:
# Time: 211220 17:42:06
# User@Host: mysite_wp[mysite_wp] @ localhost []
# Thread_id: 1667 Schema: mysite_wp QC_hit: No
# Query_time: 2.641487 Lock_time: 0.000104 Rows_sent: 10 Rows_examined: 717793
# Rows_affected: 0 Bytes_sent: 188
SET timestamp=1640047326;
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) INNER JOIN wp_postmeta AS mt1 ON ( wp_posts.ID = mt1.post_id ) WHERE 1=1 AND (
wp_postmeta.meta_key = '_bbp_last_active_time'
AND
(
( mt1.meta_key = '_bbp_forum_id' AND CAST(mt1.meta_value AS SIGNED) != '1773' )
)
) AND wp_posts.post_type = 'topic' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10;
This is a bug in bbpress – yet to be fixed.
In the meantime install
bbp style pack
which should fix
or
Put this in your child theme’s function file –
ie wp-content/themes/%your-theme-name%/functions.php
where %your-theme-name% is the name of your theme
or use
Code Snippets
if( !function_exists( 'bbpress_browser_supports_js' ) ){
function bbpress_browser_supports_js() {
echo '<script>document.body.classList.remove("no-js");</script>';
}
add_action( 'wp_footer', 'bbpress_browser_supports_js' );
}
Hi robin,
in my situation for the default language
http://domain.com/forums/topic/admin-gui/edit/
work with flag “Hide URL language information for default language”,
but for the others language the rewrite rule is triggered for edit, and add /it/, and 404 is raised.
Bye Renzo
ok, to save me searching where is ‘I can see where this is being generated in the bbpress plugin PHP code’
so typing for instance
http://domain.com/forums/topic/admin-gui/edit/
in the url does not work either?
so I’m presuming that
http://domain.com/forums/topic/admin-gui/edit/
would work ie it is the ‘/fr’ that is the problem ?
@robin-w could you check your engagements.php on your test forum?
(/yoursite/wp-content/plugins/bbpress/includes/common/engagements.php)
i’ve got
public function get_users_for_object( $object_id = 0, $meta_key = '', $meta_type = 'post' )
i think $meta_key value shouldn’t be empty…
I’m using WP in my native language.
In forum parameters I’m changing visibility option to third (make forum hidden).
just trying to translate it to en correctly
first is 'make global'
second is make private
third is make hidden
Hi! I’ve got that:
Error thrown
Call to a member function get_users_for_object() on null
When i turning visibility option to “Hide” it happens.
And I cannot access any topics and forums.I can only access profile page of bbPress
Found this method in engagements.php(/includes/common)(/includes/users), capabilities.php (/includes/users)
any suggestions to solve it?
using bbPress 2.6.9 and WordPress 5.2.13 with Pointfinder theme.
Thanks Robin.
After your comment on my other issue I pasted this code into the custom css part of my child theme and it worked when placed in there.
So I went back to my child theme and found a typo in an earlier entry which meant nothing after that was being picked up. Once that was fixed and the document version updated it picked up both these changes.
The child theme css is /themes/newsphere-child-theme/style.css?ver=1.0.2
and I’ve put “my child theme css ATTN Robin W” in it to make it findable.
So my forum-Author column is now wider as I had wanted thank you, but the forum-content area has not reduced correspondingly meaning the author section overlaps the content section and I can’t see a specific width designation for the forum-content area to update.
#bbpress-forums div.bbp-forum-content, #bbpress-forums div.bbp-reply-content, #bbpress-forums div.bbp-topic-content {
margin-left: 130px;
padding: 12px 12px 12px 0;
text-align: left;
position: relative;
}
the code is correct, but you have lots of style sheets, and I cannot see it in any.
I’m presuming it is called ‘style.css’ and if it hasn’t, perhaps you can add
/*
my child theme css
*/
or any distinctive text to the top of the style sheet, so I can see which one it is in the browser.
try this is the custom css part of your theme
#bbpress-forums div.wp-editor-container {
line-height: inherit !important;
}
The Author section seems to have a width of 115px and I’d like to widen that. I’ve tried using the below code which I pulled from a the inspect bar in Chrome and pasted into my child themes styles.css but it doesn’t work.
Can anybody help?
EddieB’s BMW R100GS
/* Make Forums author section wider */
#bbpress-forums div.bbp-forum-author, #bbpress-forums div.bbp-reply-author, #bbpress-forums div.bbp-topic-author {
width: 140px !important;
}
try this
add_filter( 'get_the_archive_title', function ($title) {
if ( is_category() ) {
$title = single_cat_title( '', false );
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
} elseif ( is_author() ) {
$title = '<span class="vcard">' . get_the_author() . '</span>' ;
}
return $title;
});
Put this in your child theme’s function file –
ie wp-content/themes/%your-theme-name%/functions.php
where %your-theme-name% is the name of your theme
or use
Code Snippets
On pages where I use the bbp-single-forum shortcode I am having an issue with the ‘Create new Topic’ text box displaying.
The topic Title field displays and can be populated fine but the main content textbox appears as a slim expandable box only a few pixels high. If you expand it no text can be entered into the box.
Also on the pages where the bbp-single-forum shortcode is being used the Home and Update icons do not display correctly, instead presenting a broken image type icon. Removing the bbp-single-forum shortcode makes the admin bar icons display correctly.
An example of a page with this issue is https://www.adventureridingnz.co.nz/motorcycles/bmw/
I am not certain, but on save a function is run that includes the wordpress function ‘sanitize_text_field’ which may well be stripping the @
what the code does is to try and find out the user_id of the name entered, and then passes this to
bbp_add_moderator( $forum_id, $user_id );
If I am guessing that this is not something you need to do too often, you could do it programatically if you know how?
in essence there are 2 functions
bbp_add_moderator( $forum_id, $user_id );
bbp_remove_moderator( $forum_id, $user_id );
Active Style Pack, logged in:
<div class="bbp-reply-author">
<a href="(....)" title="Zobacz profil: uzytkownik421" class="bbp-author-link">
<span class="bbp-author-avatar">
<img alt="" src="(....)" srcset="(....)" class="avatar avatar-80 photo" loading="lazy" width="80" height="80">
</span>
<span class="bbp-author-name">
uzytkownik421
</span>
</a>
Active Style Pack, logged out:
<div class="bbp-reply-author">
<img alt="" src="(....)" srcset="(....)" class="avatar avatar-80 photo" loading="lazy" width="80" height="80">
uzytkownik421
Looks like something replaces 'function bbp_get_reply_author_link' bbpress/includes/replies/template.php
ok, I am seeing this when logged in or logged out with style pack active
<span class="topic-author">
<a href="/forums/user/testuser1/" title="View testuser1's profile" class="bbp-author-link">
<span class="bbp-author-avatar">
<img alt="" src="..." srcset="..." class="avatar avatar-14 photo" loading="lazy" width="14" height="14">
</span>
<span class="bbp-author-name">testuser1
</span>
</a>
</span>
not sure which you are saying is different as your original post says ‘when user logged in’ in both cases??
find
wp-content/plugins/bbpress/templates/default/bbpress/feedback-no-access.php
transfer this to your pc and edit the text as desired
and save
create a directory on your theme called ‘bbpress’
ie wp-content/themes/%your-theme-name%/bbpress
where %your-theme-name% is the name of your theme
Then transfer the file you saved above and put in in the directory called bbpress that you created above, so you end up with
wp-content/themes/%your-theme-name%/bbpress/feedback-no-access.php
bbPress will now use this template instead of the original
untested, but of you add
<?php bbp_get_template_part( 'form', 'user-login' ); ?>
to the end of that form, it should also show a login