bp_core_members_shortlink_redirector( string $member_slug )
Members user shortlink redirector.
Description
Redirects x.com/members/me/_ to x.com/members/{LOGGED_IN_USER_SLUG}/_
Parameters
- $member_slug
-
(Required) The current member slug.
Return
(string) $member_slug The current member slug.
Source
File: bp-core/bp-core-catchuri.php
function bp_core_members_shortlink_redirector( $member_slug ) {
/**
* Shortlink slug to redirect to logged-in user.
*
* The x.com/members/me/* url will redirect to x.com/members/{LOGGED_IN_USER_SLUG}/*
*
* @since BuddyPress 2.6.0
*
* @param string $slug Defaults to 'me'.
*/
$me_slug = apply_filters( 'bp_core_members_shortlink_slug', 'me' );
// Check if we're on our special shortlink slug. If not, bail.
if ( $me_slug !== $member_slug ) {
return $member_slug;
}
// If logged out, redirect user to login.
if ( false === is_user_logged_in() ) {
// Add our login redirector hook.
add_action( 'template_redirect', 'bp_core_no_access', 0 );
return $member_slug;
}
$user = wp_get_current_user();
return bp_core_get_username( $user->ID, $user->user_nicename, $user->user_login );
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 2.6.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.