Skip to:
Content

BuddyPress.org

Opened 10 months ago

Last modified 5 months ago

#9235 new enhancement

Compatibility with language subdirectories

Reported by: liongrass's profile liongrass Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 12.0.0
Component: Members Keywords: dev-feedback has-patch
Cc:

Description

Hi,

since the introduction of the new Rewrite API, i haven't found a good way to make BP Profiles compatible with language subdirectories (e.g "mydomain.com/en/john-doe").

With the legacy parser, it was possible to hook in at certain points and make the whole thing work, but now there doesn't seem to be a way to do this anymore. From what i understand right now, a filter in BP_Members_Component->parse_query() would be required, just before "bp_rewrites_get_member_data()" gets called:

Before:

<?php
// Init the current member and member type.
$member      = false;
$member_type = false;
$member_data = bp_rewrites_get_member_data();

After:

<?php
$request = apply_filters('bp_members_parse_query_request',  $GLOBALS['wp']->request);
                
// Init the current member and member type.
$member      = false;
$member_type = false;
$member_data = bp_rewrites_get_member_data($request);

This would allow for the requested URI to be filtered, right before it get's passed to "bp_rewrites_get_member_data" and manipulate it such that this function knows where to look for the username in the string.

Change History (5)

#1 follow-up: @imath
10 months ago

  • Keywords reporter-feedback added

Hi,

Thanks for your feedback, there’s a way to add a root prefix to URLs, but I don’t think it would be a viable solution as I guess the « en » thing can be « fr » or « es » and rewrite rules are saved to the database.

How do you manage what you call language subdirectories with regular WordPress posts or pages ?

#2 in reply to: ↑ 1 @liongrass
10 months ago

  • Keywords reporter-feedback removed

Replying to imath:

Hi,

Thanks for your feedback, there’s a way to add a root prefix to URLs, but I don’t think it would be a viable solution as I guess the « en » thing can be « fr » or « es » and rewrite rules are saved to the database.

How do you manage what you call language subdirectories with regular WordPress posts or pages ?

I just use the Polylang plugin, you can set it up to use your site with language subdirectories.

#3 @liongrass
9 months ago

May i submit a pull request to add the aforementioned filter? If you have a better name for the filter btw let me know!

#4 @liongrass
9 months ago

  • Keywords dev-feedback added

This ticket was mentioned in PR #407 on buddypress/buddypress by Grid405.


5 months ago
#5

  • Keywords has-patch added

Adds a filter to the BP_Members_Component->parse_query method, that allows for the request object to be filtered, right before it get's passed to "bp_rewrites_get_member_data".

If member profiles are not used with the default URI, for example when using language subdirectories, BuddyPress will throw a 404. This filter allows for the requested URI to be manipulated such that "bp_rewrites_get_member_data" knows where to look for the username in the URI.

Trac ticket: https://buddypress.trac.wordpress.org/ticket/9235

Note: See TracTickets for help on using tickets.