bp_nouveau_member_locate_template_part( string $template = '' )

Locate a single member template into a specific hierarchy.

Description

Parameters

$template

(Optional) The template part to get (eg: activity, groups...).

Default value: ''

Return

(string) The located template.

Source

File: bp-templates/bp-nouveau/includes/members/functions.php

254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
function bp_nouveau_member_locate_template_part( $template = '' ) {
    $displayed_user = bp_get_displayed_user();
    $bp_nouveau     = bp_nouveau();
 
    if ( ! $template || empty( $displayed_user->id ) ) {
        return '';
    }
 
    // Use a global to avoid requesting the hierarchy for each template
    if ( ! isset( $bp_nouveau->members->displayed_user_hierarchy ) ) {
        $bp_nouveau->members->displayed_user_hierarchy = array(
            'members/single/%s-id-' . sanitize_file_name( $displayed_user->id ) . '.php',
            'members/single/%s-nicename-' . sanitize_file_name( $displayed_user->userdata->user_nicename ) . '.php',
        );
 
        /*
         * Check for profile types and add it to the hierarchy
         *
         * Make sure to register your member
         * type using the hook 'bp_register_member_types'
         */
        if ( bp_get_member_types() ) {
            $displayed_user_member_type = bp_get_member_type( $displayed_user->id );
            if ( ! $displayed_user_member_type ) {
                $displayed_user_member_type = 'none';
            }
 
            $bp_nouveau->members->displayed_user_hierarchy[] = 'members/single/%s-member-type-' . sanitize_file_name( $displayed_user_member_type ) . '.php';
        }
 
        // And the regular one
        $bp_nouveau->members->displayed_user_hierarchy[] = 'members/single/%s.php';
    }
 
    $templates = array();
 
    // Loop in the hierarchy to fill it for the requested template part
    foreach ( $bp_nouveau->members->displayed_user_hierarchy as $part ) {
        $templates[] = sprintf( $part, $template );
    }
 
    /**
     * Filters the found template parts for the member template part locating functionality.
     *
     * @since BuddyPress 3.0.0
     *
     * @param array $templates Array of found templates.
     */
    return bp_locate_template( apply_filters( 'bp_nouveau_member_locate_template_part', $templates ), false, true );
}

Changelog

Changelog
Version Description
BuddyPress 3.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.