bp_displayed_user_get_front_template( object|null $displayed_user = null )
Locate a custom user front template if it exists.
Description
Parameters
- $displayed_user
-
(Optional) Falls back to current user if not passed.
Default value: null
Return
(string|bool) Path to front template on success; boolean false on failure.
Source
File: bp-members/bp-members-template.php
function bp_displayed_user_get_front_template( $displayed_user = null ) { if ( ! is_object( $displayed_user ) || empty( $displayed_user->id ) ) { $displayed_user = bp_get_displayed_user(); } if ( ! isset( $displayed_user->id ) ) { return false; } if ( isset( $displayed_user->front_template ) ) { return $displayed_user->front_template; } // Init the hierarchy $template_names = array( 'members/single/front-id-' . sanitize_file_name( $displayed_user->id ) . '.php', 'members/single/front-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'; } $template_names[] = 'members/single/front-member-type-' . sanitize_file_name( $displayed_user_member_type ) . '.php'; } // Add The generic template to the end of the hierarchy $template_names[] = 'members/single/front.php'; /** * Filters the hierarchy of user front templates corresponding to a specific user. * * @since BuddyPress 2.6.0 * * @param array $template_names Array of template paths. */ return bp_locate_template( apply_filters( 'bp_displayed_user_get_front_template', $template_names ), false, true ); }
Changelog
Version | Description |
---|---|
BuddyPress 2.6.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.