Skip to:
Content
Pages
Categories
Search
Top
Bottom

RESOLVED-Is the Codex page wrong about front.php file?


  • ahmedmusawir
    Participant

    @ahmedmusawir

    Template Hierarchy

    The Codex page above says clearly, that if I put a front.php page in /buddypress/members/single/ … it should be picked up. Also, if I have a member type, all I have to do is this:

    /buddypress/members/single/front-member-type-{member-type}.php

    But none of the above are working. It always uses home.php … any idea why? What am I doing wrong?

Viewing 1 replies (of 1 total)

  • ahmedmusawir
    Participant

    @ahmedmusawir

    Brajesh from BuddyDev.com was gracious enough help me with the following solutions verbatim:

    Hi Moose
    Thank you for the question.

    To answer your question.

    1. The front template for member type works, but it is not what you are expecting. The front template is used to show the contents inside the content area(below the member header where you see activity etc)

    2. If your goal is to completely control the profile page layout by member type, we can easily do it by forcing bp to load our own template if exists.

    add_filter( 'bp_template_hierarchy_members_single_item', function ( $templates ) {
    
    	$member_types = bp_get_member_type( bp_displayed_user_id(), false );
    	foreach ( $member_types as $member_type ) {
    		array_unshift( $templates, "members/single/index-type-{$member_type}.php" );
    	}
    
    	return $templates;
    } );

    Now, you can create buddypress/members/single/index-type-somemembertype.php and that will be the one used for whole page(You will need to include headers/footers etc manually here).

    Regards
    Brajesh

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar