bp_core_members_shortlink_redirector

Members user shortlink redirector.

Description

(string) bp_core_members_shortlink_redirector( (string) $member_slug ); 

Redirects x.com/members/me/** to x.com/members//*

Returns (string)

$member_slug The current member slug.

Parameters (1)

0. $member_slug (string)
The current member slug.

Usage

  1. if ( !function_exists( 'bp_core_members_shortlink_redirector' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-catchuri.php'; 
  3.  
  4. // The current member slug. 
  5. $member_slug = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_core_members_shortlink_redirector($member_slug); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-core/bp-core-catchuri.php  
  1. function bp_core_members_shortlink_redirector( $member_slug ) { 
  2.  
  3. /** 
  4. * Shortlink slug to redirect to logged-in user. 
  5. * The x.com/members/me/** url will redirect to x.com/members/{LOGGED_IN_USER_SLUG}/* 
  6. * @since 2.6.0 
  7. * @param string $slug Defaults to 'me'. 
  8. */ 
  9.  
  10. // Check if we're on our special shortlink slug. If not, bail. 
  11. if ( $me_slug !== $member_slug ) { 
  12. return $member_slug; 
  13.  
  14. // If logged out, redirect user to login. 
  15. if ( false === is_user_logged_in() ) { 
  16. // Add our login redirector hook. 
  17.  
  18. return $member_slug; 
  19.  
  20. $user = wp_get_current_user(); 
  21.  
  22. return bp_core_get_username( $user->ID, $user->user_nicename, $user->user_login );