Opened 5 years ago
Last modified 10 months ago
#3355 new defect (bug)
Forum Pagination links are broken
Reported by: | SirLouen | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | needs-patch |
Cc: |
Description
I posted this issue in buddypress trac some weeks ago:
I've found that forum pagination links are broken:
Check this user for example:
https://buddypress.org/members/modemlooper/forums/
In the bottom pagination links:
But they commented that it could be an issue on bbpress
https://buddypress.trac.wordpress.org/ticket/8237#comment:3
Change History (23)
#3
@
13 months ago
@johnjamesjacoby marked the issue n°2190 as resolved 11 years ago here https://bbpress.trac.wordpress.org/ticket/2190 through fix [4741]
The issue is still there.
Tested today with BuddyPress 11.4 and 12.0.0-beta4 combined with bbPress 2.6.9 (WordPress 4.6.1)
Bug was reported also on BuddyPress trac https://buddypress.trac.wordpress.org/ticket/8237#comment:3 but I'm pretty confident this is a bbpress issue
#4
@
13 months ago
From what I managed to gather not knowing the bbpress code until now, I think the bug comes from
bbp_get_replies_pagination_base()
in /includes/replies/template.php
(for replies, equivalent for topics being bbp_get_topics_pagination_base
) https://bbpress.trac.wordpress.org/browser/trunk/src/includes/replies/template.php#L2308
// User's replies
if ( bbp_is_single_user_replies() )
$base = bbp_get_user_replies_created_url( bbp_get_displayed_user_id() );
// returns exampledomain/membres/username/forums/responses/
// Root profile page
} elseif ( bbp_is_single_user() ) {
$base = bbp_get_user_profile_url( bbp_get_displayed_user_id() );
// returns exampledomain/membres/username/
}
When using BuddyPress the function used in an other user profile is bbp_is_single_user
for the pagination links so the pagination link url does not include /forum/responses/
The solution might be in one of those functions. I guess.
#5
@
13 months ago
I'm not quite clear what you are saying - only because I don't have need of buddypress, so don't know what it us looking for :-)
from the 2 functions above, which function needs to return what different answer?
#6
@
13 months ago
On a WordPress install using BuddyPress+bbPress if you navigate to a user profile page and look at his forum history, the pagination links are :
exampledomain/membres/username/page/2/
when they should be, for replies tab as an example:
exampledomain/membres/username/forums/replies/page/2/
For a reason I'm not too sure to understand, when both plugins are enabled bbPress does not recognize the replies tab of a user profile as bbp_is_single_user_replies == true
. This returns false and then the query does not return the proper output.
11 years ago it was resolved apparently on bbPress end but the template.php code has changed since and the issue is back again. See this issue from back then https://bbpress.trac.wordpress.org/ticket/2190
On the logged in user profile, on /forums/replies bbp_is_single_user()
and bbp_is_single_user_replies
return true but on another user profile bbp_is_single_user()
returns true when bbp_is_single_user_replies
returns false.
I can't figure out why. I have notified buddypress too as the bug is affecting even their own website. I think it possibly affects a lot of website using both plugins together.
#7
@
13 months ago
thanks for prompt further info - I'm not a bbpress author, but try to help out. I'll take a further look at this shortly :-)
#8
@
12 months ago
@jgasba - ok, I've just looked at this and I am not seeing the issue, mine resolves as
exampledomain/members-2/admin/forums/replies/page/2/
as it should.
this is on a twentyten theme, with 6.4.2 and php 8.2 buddypress 11.4.0 and bbpress 2.6.9
Initial thoughts are :
- language different?
- Have you tried it with a default theme and just bbpress and buddypress to eliminate theme other plugins?
- have I done something wrong?
#9
@
12 months ago
@robin-w your answer triggered me because I thought I tested this thoroughly.
SO, I just did a new test, wiped completely and started from scratch on fresh DB and new install.
I'm on twentytwentyone theme, 6.4.2, php 8.2 buddypress 11.4.0 and bbpress 2.6.9.
I created some dummy forums, topics and 18 answers so that it switches to proposing me several pages on /membres/default/forums/replies/
At first, it worked well (good!). With the default config.
Then I adjusted the config to mimic how I used BuddyPress on the other big project I had to patch this issue:
- in /wp-admin/admin.php?page=bp-components I unticked everything but the Private Messages
- in /wp-admin/admin.php?page=bp-settings I unticked everything and used Heritage. Note that the issue is also present with Nouveau.
I'm on a French version of WordPress but do you think it could change anything? I tried switching languages and refreshing the permalinks settings between steps but it did not solve.
Important: It works well when I'm on my own profile and connected, but when viewing the page from a disconnected account, I confirm there is the bug.
#10
@
12 months ago
when you say disconnected account -
- do you mean a user who has been deleted? or what does disconnected mean?
- is this the only time you see it?
#12
@
12 months ago
I've kicked this around a bit, and this code gets you round the problem
add_filter ('bbp_is_single_user_replies' , 'bbpr_check_buddypress_user') ; add_filter ('bbp_is_single_user_topics' , 'bbpr_check_buddypress_user') ; function bbpr_check_buddypress_user ($retval= false) { if (function_exists ('buddypress')) { //check if we are on a buddpress single user page (and logged out), as this produces a pagination error in buddypress //see https://bbpress.trac.wordpress.org/ticket/3355 if (!is_user_logged_in() && bp_is_user())$retval = true ; } return $retval ; } <?php
for others coming accross this who might not be as code savvy...
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 https://wordpress.org/plugins/code-snippets/
#14
@
12 months ago
Robin, this issue also effects engagements and favorites. I'd also assume subscriptions as well, but have not tested this.
#15
@
12 months ago
Just to be as complete as possible about this and for future reference, here is how I personnaly patched it in my project:
I thought I had shared it here but can't find where I have done that
<?php /** * Fix the pagination links on Buddypress forum Replies pages */ add_filter('bbp_get_replies_pagination_base', 'fix_replies_pagination_links', 10, 2); function fix_replies_pagination_links( $base, $topic_id ) { if ( bp_is_user() ) { $base = bbp_get_user_replies_created_url( bbp_get_displayed_user_id() ); $base = trailingslashit( $base ) . user_trailingslashit( bbp_get_paged_slug() . '/%#%/' ); } return $base; } /** * Fix the pagination links on Buddypress forum Topics pages */ add_filter('bbp_get_topics_pagination_base', 'fix_topics_pagination_links', 10, 2); function fix_topics_pagination_links( $base, $topic_id ) { if ( bp_is_user() ) { $base = bbp_get_user_topics_created_url( bbp_get_displayed_user_id() ); $base = trailingslashit( $base ) . user_trailingslashit( bbp_get_paged_slug() . '/%#%/' ); } return $base; }
(shit I commented with other account, nvm)
#16
follow-up:
↓ 18
@
11 months ago
@robin-w If you are using BuddyPress 12.0.0 you can have it fixed this way:
https://gist.github.com/imath/24fdfa1b8625477e93c0daa0d90b2a44
#18
in reply to:
↑ 16
@
11 months ago
@imath - Where do we upload the php file that you created (bp-custom.php)? Is it suppose to be placed in one of the Buddypress folders? Or is the code suppose to be placed in the child theme's functions.php? TIA
#19
@
11 months ago
@hardel Think it has to go in /wp-content/plugins folder. Tried it at this site, not working- would it work for you?
#20
@
11 months ago
Yes that’s where it needs to be. Please note this will only work with BuddyPress 12.0 & the BP Classic back compatibility Add-on (as bbPress is not ready yet for 12.0)
#21
@
11 months ago
Does that mean we won't need this file when bbPress is updated to be compatible with Buddypress 12? As in, the bug will be fixed?
#22
@
11 months ago
I uploaded it to that folder, but unfortunately it does not work. I am running the latest buddypress and bbpress versions.
#23
@
10 months ago
Hi,
Can I clarify what needs adding where to resolve this please?
I'm using a multi-site, so have bp-custom.php in my wp-content folder, is this correct?
The content is like this:
<?php // your php custom code goes below this line. define( 'BP_ENABLE_MULTIBLOG', true ); // Exit if accessed directly. if ( ! defined( 'ABSPATH' ) ) { exit; } /** * bbPress should include such an action into its `src/includes/extend/buddypress/members.php` file. */ function fix_bbpress_member_pagination( &$query ) { if ( bp_is_user() && bp_is_current_component( 'forums' ) ) { $action_variables = (array) bp_action_variables(); if ( function_exists( 'bbp_get_paged_slug' ) && bbp_get_paged_slug() === bp_action_variable( 0 ) ) { $query->set( 'paged', (int) bp_action_variable( 1 ) ); } } } add_action( 'bp_members_parse_query', 'fix_bbpress_member_pagination' );
Does that look correct? Is there something else I need to add anywhere?
I've added the above but the pagination is still wrong and goes to a 404.
I'm using:
WordPress 6.4.2
bbPress 2.6.9
BuddyPress 12.1.1
BuddyPress Multi Network 1.0.3
bbp style pack 5.8.0
Profile Builder 3.10.7
Profile Builder Elite 3.9.9
I'm using an FSE theme with compatability turned on in bbp style pack.
Many Thanks,
Andy
Bumping this issue as I noticed the same thing and I'm retracing that breadcrumb. BuddyPress + bbpress combo produces broken pagination links on members profiles.
Anything new on this 4 years old issue?