[buddypress-trac] [BuddyPress Trac] #6325: Route /me/*/ to /members/<me>/*/

buddypress-trac noreply at wordpress.org
Thu Apr 14 19:59:56 UTC 2016


#6325: Route /me/*/ to /members/<me>/*/
------------------------------------+-----------------------
 Reporter:  DJPaul                  |       Owner:  DJPaul
     Type:  enhancement             |      Status:  assigned
 Priority:  normal                  |   Milestone:  2.6
Component:  API - Rewrite Rules     |     Version:
 Severity:  normal                  |  Resolution:
 Keywords:  dev-feedback has-patch  |
------------------------------------+-----------------------

Comment (by r-a-y):

 > It works fine in my browser, but is the
 bp_core_set_uri_globals_member_slug hook too late to be starting
 redirects?

 It's slightly too early.  That's why the unit tests are complaining ;)  We
 should preferably be doing this redirect on the `'template_redirect'`
 hook.

 I've refreshed `02.patch` to use an anonymous function to hook onto
 `'bp_template_redirect'` to do the login redirect.  This fixes up the unit
 test since the `'bp_template_redirect'` hook isn't run during unit tests.

 If we hate anonymous functions, we can introduce a new function for this.
 Something like:

 {{{#!php
 /**
  * Function to perform a generic no access redirect.
  *
  * This should only be run on the 'template_redirect' hook.
  *
  * @since 2.6.0
  */
 function bp_core_do_no_access_redirect() {
         // Bail if we're using this function before the
 'template_redirect' hook.
         if ( false === did_action( 'template_redirect' ) ) {
                 _doing_it_wrong( __FUNCTION__, __( "This function should
 only run on the 'template_redirect' hook.", 'buddypress' ), 'BP 2.6.0' );
                 return;
         }

         bp_core_no_access();
         exit();
 }
 }}}

 I also want to return to this potential issue:

 > My only concern is do we do this redirection for root profiles as well
 (x.com/me/*)? If we do, there is the potential to be a conflict with a
 page with the slug /me/. It's easy enough to disable this if root profiles
 is enabled. Just need some dev feedback.

 I don't think this is really an issue.  If there is a conflict, a plugin
 dev can always filter our special `'me'` slug to something else.

 FWIW, if root profiles is enabled and there is a username called `'test'`
 and there is a page with the slug `test`, BP will take precedence.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/6325#comment:20>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list