Opened 6 years ago
Closed 4 years ago
#8029 closed defect (bug) (fixed)
bp_has_members misbehaving on Nouveau Profile Home page widgets area
Reported by: | Venutius | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | trivial | Version: | |
Component: | Templates | Keywords: | |
Cc: |
Description
bp_has_members when executed in the BP Nouveau profile home page widget area using the include= argument fails to return the included user id's and instead returns the displayed user id.
If you add the BudduPress Followers Following widget to the BP Nouveau profile home page widget area it fails to function correctly, returning the displayed user id rather than the id's of the of the following.
To test this you can add the Following widget to the sidebar of the same page and it works correctly, but in the home page widget area it does not.
Change History (4)
#2
@
6 years ago
I've found the reason for this behaviour, it's from bp-templates/bp-nouveau/includes/members/functions.php line 400:
function bp_nouveau_member_members_widget_overrides( $args = array() ) { // Do nothing for the friends widget if ( ! empty( $args['user_id'] ) && (int) $args['user_id'] === (int) bp_displayed_user_id() ) { return $args; } return array_merge( $args, array( 'include' => bp_displayed_user_id(), ) ); }
This filter is being driven by the following in line 283 of bp-core/bp-core functions:
if ( !empty( $filter_key ) ) { $r = apply_filters( 'bp_before_' . $filter_key . '_parse_args', $r ); }
For the bp_has_members() calls I am making, $filter_key should be empty and it should not be firing. The filter being called is bp_before_has_members_parse_args
So it appears that somehow for Home page widgets a filter key of has_members is being set
I've been looking into this further and it seems that the issue is within bp_parse_args() in bp_has_members. Replacing this is wp_parse_args() fixes the issue.