Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

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

  • stunomatic
    Participant

    @stunomatic

    Guys can you help me out with this one. I tried all your methods and it is still showing all members if non selected.

    Thanks


    stunomatic
    Participant

    @stunomatic

    Anyone ?


    stunomatic
    Participant

    @stunomatic

    Any Help ?


    stunomatic
    Participant

    @stunomatic

    I am back to start. If there id’s it shows only specific ids but if its null then it shows all the users :s

    <?php 		
    $contrytoggle = get_field( "country_toggle" );
    $contrypri = get_field( "select_country" ); ?>
    
    <?php echo $contrytoggle; ?>
    
    <?php $custom_ids = my_custom_ids($contrytoggle, $contrypri);  
    
     // $has_members_args = array(
       // 'include' => $custom_ids,
    // ); 
      
      echo $custom_ids;   // it echo no id and still it shows all the users 
       
      if ( bp_has_members( $custom_ids )  ) :
    
     ?> 
      
    	   	<ul>
      <?php while ( bp_members() ) : bp_the_member(); ?>
     
        <li>
          <div class="item-avatar">
             <a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar(); ?></a>
          </div>
     
          <div class="item">
            <div class="item-title">
               <a href="<?php bp_member_permalink(); ?>"><?php bp_member_name(); ?></a>
          </div>
    	</li>
    	  
    	   <?php endwhile; ?>
    
    	</ul>
    	
    <?php else: ?>
     
        <div id="message" class="info">
          <p><?php _e( "Sorry, no members were found.", 'buddypress' ); ?></p>
       </div>
       
    
    	
    <?php endif; ?>
    </div>
    
        

    stunomatic
    Participant

    @stunomatic

    If I pass include inside if then,

    echo $contrytoggle; = It shows 4 id’s 6,7,8,9

    and below code show only 3 users… user with 6th ID is missing

    <?php 		
    $contrytoggle = get_field( "country_toggle" );
    $contrypri = get_field( "select_country" ); ?>
    
    <?php echo $contrytoggle; ?>
    
    <?php $custom_ids = my_custom_ids($contrytoggle, $contrypri);  
    
     // $has_members_args = array(
       // 'include' => $custom_ids,
    // ); 
      
      echo $custom_ids; 
       
      if ( bp_has_members( 'include=' . $custom_ids ) ) :
    
     ?> 
      
    	   	<ul>
      <?php while ( bp_members() ) : bp_the_member(); ?>
     
        <li>
          <div class="item-avatar">
             <a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar(); ?></a>
          </div>
     
          <div class="item">
            <div class="item-title">
               <a href="<?php bp_member_permalink(); ?>"><?php bp_member_name(); ?></a>
          </div>
    	</li>
    	  
    	   <?php endwhile; ?>
    
    	</ul>
    	
    <?php else: ?>
     
        <div id="message" class="info">
          <p><?php _e( "Sorry, no members were found.", 'buddypress' ); ?></p>
       </div>
       
    
    	
    <?php endif; ?>
    </div>
    

    stunomatic
    Participant

    @stunomatic

    Hi,

    Thanks Boone for replying.

    I did as you said but still this while loop shows all the user profiles.

    If I echo ” echo $custom_ids; ” This shows correct number of ids

    Is there something I need to do with while loop as well ?

    Thanks

    <?php 		
    $contrytoggle = get_field( "country_toggle" );
    $contrypri = get_field( "select_country" ); ?>
    
    <?php echo $contrytoggle; ?>
    
    <?php $custom_ids = my_custom_ids($contrytoggle, $contrypri);
    
      $has_members_args = array(
        'include' => $custom_ids,
    ); 
      
      echo $custom_ids;   // This shows correct number of ids
       
      if ( bp_has_members() ) :
    
     ?> 
      
    	   	<ul>
      <?php while ( bp_members() ) : bp_the_member(); ?>
     
        <li>
          <div class="item-avatar">
             <a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar(); ?></a>
          </div>
     
          <div class="item">
            <div class="item-title">
               <a href="<?php bp_member_permalink(); ?>"><?php bp_member_name(); ?></a>
          </div>
    	</li>
    	  
    	   <?php endwhile; ?>
    
    	</ul>
    	
    <?php else: ?>
     
        <div id="message" class="info">
          <p><?php _e( "Sorry, no members were found.", 'buddypress' ); ?></p>
       </div>
       
    
    	
    <?php endif; ?>
    </div>
    

    stunomatic
    Participant

    @stunomatic

    Hi Shane,

    Even if I check condition it still shows all members.

     <?php       
    
        <?php if ( !empty(bp_has_members( my_custom_ids( 'country', 'usa' ) ) ) ) : ?>  
    
        <ul>
      <?php while ( bp_members() ) : bp_the_member(); ?>
    
        <li>
          <div class="item-avatar">
             <a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar(); ?></a>
          </div>
    
          <div class="item">
            <div class="item-title">
               <a href="<?php bp_member_permalink(); ?>"><?php bp_member_name(); ?></a>
          </div>
        </li>
    
           <?php endwhile; ?>
    
        </ul>
    
    <?php else: ?>
    
       <div id="message" class="info">
          <p><?php _e( "Sorry, no members were found.", 'buddypress' ); ?></p>
       </div>
    
    <?php endif; ?>
    </div>

    stunomatic
    Participant

    @stunomatic

    I use the function “my_custom_ids” Loop


    stunomatic
    Participant

    @stunomatic

    Thanks @shanebp for response. OK I played around and here is my code. Its working fine but with one issue i.e

    If there is no value it echo’s all the members.

    
    <?php 		
    $contrytoggle = get_field( "country_toggle" );
    $contrypri = get_field( "select_country" ); ?>
    
         <?php echo $contrytoggle; ?>
    
    	<?php if ( bp_has_members( my_custom_ids( $contrytoggle, $contrypri ) ) ) : ?>
    	
    	<ul>
      <?php while ( bp_members() ) : bp_the_member(); ?>
     
        <li>
          <div class="item-avatar">
             <a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar(); ?></a>
          </div>
     
          <div class="item">
            <div class="item-title">
               <a href="<?php bp_member_permalink(); ?>"><?php bp_member_name(); ?></a>
          </div>
    	</li>
    	  
    	   <?php endwhile; ?>
    
    	</ul>
    	
    <?php else: ?>
     
       <div id="message" class="info">
          <p><?php _e( "Sorry, no members were found.", 'buddypress' ); ?></p>
       </div>
       
       
    	
    <?php endif; ?>

    stunomatic
    Participant

    @stunomatic

    NO one ?

Viewing 10 replies - 1 through 10 (of 10 total)
Skip to toolbar