Opened 8 years ago
Last modified 8 years ago
#7736 new defect (bug)
bp_get_groups_slug filter and Profile screen
| Reported by: | jozik | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Contributions |
| Component: | Route Parser | Version: | 1.5 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
If we apply 'bp_get_groups_slug' filter, no groups are listed on Profile/Groups/Membership screen.
Looks like BP fails to recognize current component so groups are not listed.
Steps to reproduce
- Create BuddyPress Group and add yourself as member
- Add filter 'bp_get_groups_slug' to return altered slug (e.g. return "{$slug}_en")
- Visit /members/admin/groups_en/
- List is empty
- Disable filter
- Visit /members/admin/groups/
- Group is listed
Is something else needed to make this work?
WPML users asked to localize this string, so it could be a variable applied on frontend.
Is there a better way to do it?
Change History (6)
#2
@
8 years ago
- Component Core → Route Parser
- Keywords dev-feedback removed
- Milestone Awaiting Review → Awaiting Contributions
Having proper customisable links for all of these URLs is something we've all wanted. This sort of report is going to be the tip of a very large iceberg.
I would not oppose this specific change being made as its own thing. I think we'd all assume that filtering a group slug should not break the "is this a groups screen" logic.
#4
@
8 years ago
How are you implementing your filter?
It should look like this:
function my_bp_is_current_component_groups_slug_override( $retval, $component ) {
if ( bp_current_component() === bp_get_groups_slug() && 'groups' === $component ) {
return true;
}
return $retval;
}
add_filter( 'bp_is_current_component', 'my_bp_is_current_component_groups_slug_override', 10, 2 );
Depending on how you are filtering 'bp_get_groups_slug', you might need to change the check in the example above to do comparisons against a list of your group slugs.
#5
@
8 years ago
@r-a-y Thank you for help.
Yes, implemented like that. Returning TRUE does not change anything.
#6
@
8 years ago
Works for me using a custom group slug while filtering 'bp_get_groups_slug' and viewing example.com/members/USER/CUSTOM_SLUG, except the select dropdown filter and pagination do not appear in the group loop, which would probably require more work. You'll have to look into that yourself.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
If you filter
'bp_get_groups_slug', you are changing how thebp_is_groups_component()function is returned. That function will always return false on your customized groups page.So what you'll have to do is to also filter
'bp_is_current_component'sobp_is_groups_component()will return true with your custom group slug:https://buddypress.trac.wordpress.org/browser/tags/2.9.3/src/bp-core/bp-core-template.php?marks=1706-1714#L1706
I'm not sure if this is something that BuddyPress core should automatically implement or not, but that should get you up-and-running.
Tagged with
dev-feedbackto see if we should automaticaly implement this or not.