Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/09/2015 03:31:18 PM (5 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/src/bp-members/bp-members-template.php

    r9698 r9723  
    516516    }
    517517
     518    $member_type = bp_get_current_member_type();
     519    if ( ! $member_type && ! empty( $_GET['member_type'] ) ) {
     520        if ( is_array( $_GET['member_type'] ) ) {
     521            $member_type = $_GET['member_type'];
     522        } else {
     523            // Can be a comma-separated list.
     524            $member_type = explode( ',', $_GET['member_type'] );
     525        }
     526    }
     527
    518528    // type: active ( default ) | random | newest | popular | online | alphabetical
    519529    $r = bp_parse_args( $args, array(
     
    529539
    530540        'user_id'         => $user_id, // Pass a user_id to only show friends of this user
    531         'member_type'     => '',
     541        'member_type'     => $member_type,
    532542        'search_terms'    => null,     // Pass search_terms to filter users by their profile data
    533543
     
    17971807        return apply_filters( 'bp_get_loggedin_user_username', $username );
    17981808    }
     1809/**
     1810 * Echo the current member type message.
     1811 *
     1812 * @since BuddyPress (2.3.0)
     1813 */
     1814function bp_current_member_type_message() {
     1815    echo bp_get_current_member_type_message();
     1816}
     1817    /**
     1818     * Generate the current member type message.
     1819     *
     1820     * @since BuddyPress (2.3.0)
     1821     *
     1822     * @return string
     1823     */
     1824    function bp_get_current_member_type_message() {
     1825        $type_object = bp_get_member_type_object( bp_get_current_member_type() );
     1826
     1827        $message = sprintf( __( 'Viewing members of the type: %s', 'buddypress' ), '<strong>' . $type_object->labels['singular_name'] . '</strong>' );
     1828
     1829        return apply_filters( 'bp_get_current_member_type_message', $message );
     1830    }
    17991831
    18001832/** Signup Form ***************************************************************/
Note: See TracChangeset for help on using the changeset viewer.