Skip to:
Content

BuddyPress.org

Ticket #6477: 6477.diff

File 6477.diff, 1.7 KB (added by boonebgorges, 9 years ago)
  • src/bp-core/bp-core-catchuri.php

    diff --git src/bp-core/bp-core-catchuri.php src/bp-core/bp-core-catchuri.php
    index 3c6bc5b..5917b84 100644
    function bp_core_set_uri_globals() { 
    241241
    242242        // Rejig the offset
    243243        if ( !empty( $slug ) && ( 1 < count( $slug ) ) ) {
    244                 array_pop( $slug );
    245                 $uri_offset = count( $slug );
     244                // Only offset if not on a root profile. Fixes issue when Members page is nested.
     245                if ( false === $root_profile ) {
     246                        array_pop( $slug );
     247                        $uri_offset = count( $slug );
     248                }
    246249        }
    247250
    248251        // Global the unfiltered offset to use in bp_core_load_template().
  • tests/phpunit/testcases/routing/root-profiles.php

    diff --git tests/phpunit/testcases/routing/root-profiles.php tests/phpunit/testcases/routing/root-profiles.php
    index fc6403e..e889eef 100644
    class BP_Tests_Routing_Members_Root_Profiles extends BP_UnitTestCase { 
    4242                $this->assertEquals( $this->u->ID, bp_displayed_user_id() );
    4343        }
    4444
     45        /**
     46         * @ticket BP6475
     47         */
     48        public function test_member_permalink_when_members_page_is_nested_under_wp_page() {
     49                $p = $this->factory->post->create( array(
     50                        'post_type' => 'page',
     51                        'post_name' => 'foo',
     52                ) );
     53
     54                $members_page = get_page_by_path( 'members' );
     55                wp_update_post( array(
     56                        'ID' => $members_page->ID,
     57                        'post_parent' => $p,
     58                ) );
     59
     60                $domain = home_url( $this->u->user_nicename );
     61                $this->go_to( $domain );
     62
     63                $this->assertTrue( bp_is_user() );
     64                $this->assertTrue( bp_is_my_profile() );
     65                $this->assertEquals( $this->u->ID, bp_displayed_user_id() );
     66        }
     67
    4568        public function test_member_activity_page() {
    4669                $url = home_url( $this->u->user_nicename ) . '/' . bp_get_activity_slug();
    4770                $this->go_to( $url );