| | 538 | * Members user shortlink redirector. |
| | 539 | * |
| | 540 | * Redirects x.com/members/me/* to x.com/members/{LOGGED_IN_USER_SLUG}/* |
| | 541 | * |
| | 542 | * @since 2.6.0 |
| | 543 | * |
| | 544 | * @param string $member_slug The current member slug. |
| | 545 | */ |
| | 546 | function bp_core_members_shortlink_redirector( $member_slug ) { |
| | 547 | /** |
| | 548 | * Shortlink slug to redirect to logged-in user. |
| | 549 | * |
| | 550 | * x.com/members/me/* will redirect to x.com/members/{LOGGED_IN_USER_SLUG}/* |
| | 551 | * |
| | 552 | * @since 2.6.0 |
| | 553 | * |
| | 554 | * @var string $slug Defaults to 'me'. |
| | 555 | */ |
| | 556 | $me_slug = apply_filters( 'bp_core_members_shortlink_slug', 'me' ); |
| | 557 | |
| | 558 | // Check if we're on our special shortlink slug. If not, bail. |
| | 559 | if ( $me_slug !== $member_slug ) { |
| | 560 | return $member_slug; |
| | 561 | } |
| | 562 | |
| | 563 | // If logged out, redirect user to login. |
| | 564 | if ( false === is_user_logged_in() ) { |
| | 565 | // Add our login redirector hook. |
| | 566 | add_action( 'template_redirect', 'bp_core_no_access', 0 ); |
| | 567 | |
| | 568 | return $member_slug; |
| | 569 | } |
| | 570 | |
| | 571 | $user = wp_get_current_user(); |
| | 572 | |
| | 573 | return bp_core_get_username( $user->ID, $user->user_nicename, $user->user_login ); |
| | 574 | } |
| | 575 | add_filter( 'bp_core_set_uri_globals_member_slug', 'bp_core_members_shortlink_redirector' ); |
| | 576 | |
| | 577 | /** |