Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Custom Members Directory in a New Template


  • lesanis
    Participant

    @lesanis

    Hello,

    How could I make a custom Members Directory in a new template with members that have chosen a specific value of an xprofile field?

    Here is what I have done. I have created a new template members-loop-london.php (copy of members-loop.php) in the members folder and I would like to display there only members that have chosen at the xprofile field City the value London. Then according to this link about “bp_parse_args()” https://buddypress.trac.wordpress.org/browser/tags/2.2.1/src/bp-members/bp-members-template.php#L461 I added in the template the function:

    function mine_bp_has_members( $args = '' ) {
    	        global $members_template;
    	
            // Default user ID
            $user_id = 0;
    	
    	       
    	        $r = bp_parse_args( $args, array(
    	                
    	                'search_terms'    => 'London',     // Pass search_terms to filter users by their profile data
    	
    	        ), 'has_members' );
    
    	        // Pass a filter if ?s= is set.
    	        if ( is_null( $r['search_terms'] ) ) {
    	                if ( !empty( $_REQUEST['s'] ) ) {
    	                        $r['search_terms'] = $_REQUEST['s'];
    	                } else {
    	                        $r['search_terms'] = false;
    	                }
    	        }
    	
    	     
    	        // Query for members and populate $members_template global
    	        $members_template = new BP_Core_Members_Template(
    	               
    	                $r['search_terms'],
    	               
    	        );
    	
    	   
    	        return apply_filters( 'mine_bp_has_members', $members_template->has_members(), $members_template );     
    }

    but nothing changed. Still my custom directory was showing all the members of website..What am I doing wrong?

Viewing 3 replies - 1 through 3 (of 3 total)

  • danbp
    Participant

    @danbp

    Hi,
    you do it wrong and it is much more simple to make customization by reading the codex.

    The only thing you have to do on the custom template ( i assume you already have the template) is to create a custom member loop. To fecth the correct data to show and how to do that is explained in details here (see Code Examples):

    Members Loop


    lesanis
    Participant

    @lesanis

    I don’t believe that it was that simple… Danmp I want to kiss you!!!!! I had read the codex previously but I was so tired and I didn’t understand what I should do. Thank you very very very much once more!!!


    danbp
    Participant

    @danbp

    You’re welcome ! Close your eyes now and go to sleep ! Tomorrow will be another day. 😉

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Custom Members Directory in a New Template’ is closed to new replies.
Skip to toolbar