Skip to:

Opened 8 years ago

Closed 23 months ago

Last modified 23 months ago

#7308 closed defect (bug) (fixed)

Make function "bp_core_menu_highlight_parent_page" multisite-aware

Reported by: martinutopia's profile martinutopia Owned by: imath's profile imath
Milestone: 11.0.0 Priority: normal
Severity: normal Version: 2.7
Component: Core Keywords:


In my WP-multisite I want to loop over posts in a WP-Menu of my main site that is no buddypress-Site. So I'm using switch_to_blog() to get the data from my main site.

I get an error in the file buddypress/bp-core/bp-core-filters.php on line 199 that the second parameter of in_array is not an array. (it's null because the get_post() on line 198 returns null)

My suggested fix is to test if we are in a switch_to_blogs context. For that I suggest following fix on line 171 (add a check of ms_is_switched()):

if ( ! is_buddypress() || ms_is_switched() ) 


Attachments (1)

7308.patch (669 bytes) - added by rudlinkon 23 months ago.
return from the function if not bp_is_root_blog()

Download all attachments as: .zip

Change History (12)

#1 @DJPaul
8 years ago

  • Keywords good-first-bug needs-patch added
  • Milestone changed from Awaiting Review to 2.8

Hi @martinutopia

Thanks for the bug report (your first, I think; welcome!).

I think we'll fix this with our bp_is_root_blog function rather than ms_is_switched (the latter function is only present if multisite is enabled). Alternately, BuddyPress could do its own switch_to_blog inside the function. I need to spend more than 5 minutes considering the best fix to be sure, but we can definitely get this in for our next major release (2.8; early next year).

For now, I'd suggest you hook a function to that action with a higher priority, and inside that function callback, unhook the BuddyPress function from that action if ms_is_switched since that apparently works well for you.

#2 @DJPaul
7 years ago

  • Milestone changed from 2.8 to Future Release

This ticket was mentioned in PR #22 on buddypress/buddypress by robinwpdeveloper.

23 months ago

  • Keywords has-patch added; needs-patch removed

bp_is_root_blog check added on bp_core_menu_highlight_parent_page function

Trac ticket: 7308

robinwpdeveloper commented on PR #22:

23 months ago

@imath can you please review this pull request.
This is my first contribution to buddypress :)

#5 @rudlinkon
23 months ago

The PR looks good to me according to @DJPaul's suggestions. Thanks @robinwpdeveloper for your first contribution in BuddyPress

imath commented on PR #22:

23 months ago

@robinwpdeveloper Sure & with great pleasure! Thanks a lot for this first PR 😍. Don't hesitate to pull more requests 👌

#7 @imath
23 months ago

  • Keywords needs-patch added; has-patch removed
  • Milestone changed from Awaiting Contributions to 11.0.0

23 months ago

return from the function if not bp_is_root_blog()

#8 in reply to: ↑ 6 @rudlinkon
23 months ago

  • Keywords good-first-bug needs-patch removed

Replying to imath:

imath commented on PR #22:

@robinwpdeveloper Sure & with great pleasure! Thanks a lot for this first PR 😍. Don't hesitate to pull more requests 👌

Yes, you are absolutely right we have to return from the function if it is not bp_is_root_blog(). I just uploaded a patch you may check it.

imath commented on PR #22:

23 months ago

FYI, a patch was added to our Trac ticket about it, so I'm going to close this PR. I hope you won't be disappointed, no worries about the credit/prop, I'll add your WordPress username to my commit.

#10 @imath
23 months ago

  • Owner set to imath
  • Resolution set to fixed
  • Status changed from new to closed

In 13322:

Only filter pages/menu list CSS classes on the root blog

To make sure a pages list or a menu highlight the current BuddyPress page or the parent/ancestor of a displayed component' single item, we use a filter that should only run on the WordPress site BuddyPress is activated. Taking this precaution will save our users from potential warning notices that were brought to our attention when BuddyPress is network activated.

Props robinwpdeveloper, martinutopia, DJPaul, rudlinkon

Fixes #7308

robinwpdeveloper commented on PR #22:

23 months ago

Thank you very much @imath :)

Note: See TracTickets for help on using tickets.