Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/19/2020 09:21:19 PM (14 months ago)
Author:
imath
Message:

Introduce a new template tag to list a user's member types

Just like Group Types can be listed into the displayed Group's header thanks to a specific template tag, Member types now have their own template tag bp_member_type_list() to do the same into the displayed user's header.

BP Nouveau is using this tag. Its header templates and styles has been updated to optimize the output of this list.

By default Member Types will not be displayed, their corresponding object will need to have their show_in_list property set to true.

Fixes #8394

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/bp-members-functions.php

    r12776 r12797  
    27192719            'bp_type_id_label'           => _x( 'Member Type ID', 'BP Member type ID label', 'buddypress' ),
    27202720            'bp_type_id_description'     => _x( 'Enter a lower-case string without spaces or special characters (used internally to identify the member type).', 'BP Member type ID description', 'buddypress' ),
     2721            'bp_type_show_in_list'       => _x( 'Show on Member', 'BP Member type show in list', 'buddypress' ),
    27212722        )
    27222723    );
     
    27632764    if ( bp_get_member_type_tax_name() === $taxonomy ) {
    27642765
    2765         // Directory
     2766        // Directory.
    27662767        if ( isset( $schema['bp_type_has_directory']['description'] ) ) {
    27672768            $schema['bp_type_has_directory']['description'] = __( 'Make a list of members matching this type available on the members directory.', 'buddypress' );
    27682769        }
    27692770
    2770         // Slug
     2771        // Slug.
    27712772        if ( isset( $schema['bp_type_directory_slug']['description'] ) ) {
    27722773            $schema['bp_type_directory_slug']['description'] = __( 'Enter if you want the type slug to be different from its ID.', 'buddypress' );
    27732774        }
     2775
     2776        // List.
     2777        $schema['bp_type_show_in_list'] = array(
     2778            'description'       => __( 'Show where member types may be listed, like in the member header.', 'buddypress' ),
     2779            'type'              => 'boolean',
     2780            'single'            => true,
     2781            'sanitize_callback' => 'absint',
     2782        );
    27742783    }
    27752784
     
    28112820 *                                      Pass a string to customize the slug. Pass `false` to disable.
    28122821 *                                      Default: true.
     2822 *     @type bool        $show_in_list  Whether this member type should be shown in lists rendered by
     2823 *                                      bp_member_type_list(). Default: false.
     2824 *     @type bool        $code          Whether this member type is registered using code. Default: true.
     2825 *     @type int         $db_id         The member type term ID. Default: 0.
    28132826 * }
    28142827 * @return object|WP_Error Member type object on success, WP_Error object on failure.
     
    28242837        'labels'        => array(),
    28252838        'has_directory' => true,
     2839        'show_in_list'  => false,
    28262840        'code'          => true,
    28272841        'db_id'         => 0,
     
    28722886        $r['has_directory']  = false;
    28732887    }
     2888
     2889    // Show the list of member types on front-end (member header, for now).
     2890    $r['show_in_list'] = (bool) $r['show_in_list'];
    28742891
    28752892    $bp->members->types[ $member_type ] = $type = (object) $r;
Note: See TracChangeset for help on using the changeset viewer.