Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/09/2015 03:31:18 PM (10 years ago)
Author:
boonebgorges
Message:

Introduce member-type-specific Members directories.

The new 'has_directory' argument for bp_register_member_type() allows
developers to specify whether a list of members matching a given type 'foo'
should be available at http://example.com/members/type/foo/. A slug can be
passed to 'has_directory' to customize the URL used for the member type's
directory.

Note that plugins registering member types must do so at the new hook
'bp_register_member_types' in order to be able to customize the 'has_directory'
value (from its default of true).

bp_has_members() automatically detects the presence of a member type in a
URL. When no member type of the form example.com/members/type/foo/ is found,
URLs of the form example.com/members/?member_type=foo will be detected.

See #6286.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/members/types.php

    r9611 r9723  
    7474    }
    7575
     76    /**
     77     * @ticket BP6286
     78     */
     79    public function test_bp_register_member_type_has_directory_should_default_to_true() {
     80        $object = bp_register_member_type( 'foo', array(
     81            'has_directory' => true,
     82        ) );
     83
     84        $this->assertTrue( $object->has_directory );
     85        $this->assertSame( 'foo', $object->directory_slug );
     86    }
     87
     88    /**
     89     * @ticket BP6286
     90     */
     91    public function test_bp_register_member_type_has_directory_true() {
     92        $object = bp_register_member_type( 'foo', array(
     93            'has_directory' => true,
     94        ) );
     95
     96        $this->assertTrue( $object->has_directory );
     97        $this->assertSame( 'foo', $object->directory_slug );
     98    }
     99
     100    /**
     101     * @ticket BP6286
     102     */
     103    public function test_bp_register_member_type_should_store_has_directory_false() {
     104        $object = bp_register_member_type( 'foo', array(
     105            'has_directory' => false,
     106        ) );
     107
     108        $this->assertFalse( $object->has_directory );
     109        $this->assertSame( '', $object->directory_slug );
     110    }
     111
     112    /**
     113     * @ticket BP6286
     114     */
     115    public function test_bp_register_member_type_should_store_has_directory_string() {
     116        $object = bp_register_member_type( 'foo', array(
     117            'has_directory' => 'foos',
     118        ) );
     119
     120        $this->assertTrue( $object->has_directory );
     121        $this->assertSame( 'foos', $object->directory_slug );
     122    }
     123
    76124    public function test_bp_get_member_type_object_should_return_null_for_non_existent_member_type() {
    77125        $this->assertSame( null, bp_get_member_type_object( 'foo' ) );
Note: See TracChangeset for help on using the changeset viewer.