Skip to:
Content

BuddyPress.org

Opened 7 years ago

Last modified 6 years ago

#7736 new defect (bug)

bp_get_groups_slug filter and Profile screen

Reported by: jozik's profile jozik Owned by:
Milestone: Awaiting Contributions Priority: normal
Severity: normal Version: 1.5
Component: Route Parser 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

  1. Create BuddyPress Group and add yourself as member
  2. Add filter 'bp_get_groups_slug' to return altered slug (e.g. return "{$slug}_en")
  3. Visit /members/admin/groups_en/
  4. List is empty
  5. Disable filter
  6. Visit /members/admin/groups/
  7. 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)

#1 @r-a-y
7 years ago

  • Keywords dev-feedback added
  • Version set to 1.5

If you filter 'bp_get_groups_slug', you are changing how the bp_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' so bp_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-feedback to see if we should automaticaly implement this or not.

Last edited 7 years ago by r-a-y (previous) (diff)

#2 @DJPaul
7 years ago

  • Component changed from Core to Route Parser
  • Keywords dev-feedback removed
  • Milestone changed from Awaiting Review to 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.

#3 @jozik
6 years ago

Just FYI - suggestion from @r-a-y is not improving things - still no results.

#4 @r-a-y
6 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.

Last edited 6 years ago by r-a-y (previous) (diff)

#5 @jozik
6 years ago

@r-a-y Thank you for help.
Yes, implemented like that. Returning TRUE does not change anything.

#6 @r-a-y
6 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.

Note: See TracTickets for help on using tickets.