Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

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

  • rianhall
    Participant

    @rianhall

    This is really odd. I must have had something cached, because it it working now. Hmmmm.

    I guess I’ll keep an eye on it, but it does seem to be working. Thanks a million!!!


    rianhall
    Participant

    @rianhall

    Thanks for the code and instructions. Unfortunately, it is still not working. Here is exactly what I did:
    1. Copied the code.
    2. Removed the code I had in the functions.php file and pasted the new code in it.
    3. Reverted my member-loop.php file to it’s original state, free from any customizations.
    4. Logged into my site
    5. Went to the members list.

    Result:
    I am still seeing the Administrator and Subscriber users.

    Any other ideas or am I doing something wrong?


    rianhall
    Participant

    @rianhall

    Any one have any suggestions?


    rianhall
    Participant

    @rianhall

    I am still having this problem and REALLY need a solution. I’m not a developer so ca anyone walk me through what I need to do?

    so far I have added this to my functions.php

    // to exclude only defined roles in the Buddypress Members LOOP
    
    function exclude_by_role($exclude_roles) {
    
    $memberArray = array();
    
    if (bp_has_members()) :
    while (bp_members()) : bp_the_member();
    $user = new WP_User( bp_get_member_user_id() );
    $user_role = $user->roles[0];
    foreach ($exclude_roles as $exclude_role) {
    if ($exclude_role==$user_role) {
    array_push($memberArray, $user->ID);
    break;
    }
    }
    endwhile;
    endif;
    
    $theExcludeString=implode(",",$memberArray);
    
    return $theExcludeString;
    }
    

    Then added this to my member-loop.php

     
    $excluded_roles = array ('administrator', 'author', 'subscriber'); // this can be any roles you have set up
    	if (bp_has_members( 'exclude=' . exclude_by_role($excluded_roles) . '&' . bp_ajax_querystring( 'members' ) ) ) : 
    

    Unfortunately, no luck. It is not excluding any of the three roles noted above.


    rianhall
    Participant

    @rianhall

    The Code from “SOLVED: Limit Members Loop by Profile Fields” seem easy to implement. I added this to my function.php

    // to exclude only defined roles in the Buddypress Members LOOP
    
    function exclude_by_role($exclude_roles) {
    
    $memberArray = array();
    
    if (bp_has_members()) :
    while (bp_members()) : bp_the_member();
    $user = new WP_User( bp_get_member_user_id() );
    $user_role = $user->roles[0];
    foreach ($exclude_roles as $exclude_role) {
    if ($exclude_role==$user_role) {
    array_push($memberArray, $user->ID);
    break;
    }
    }
    endwhile;
    endif;
    
    $theExcludeString=implode(",",$memberArray);
    
    return $theExcludeString;
    }

    I then added this to my member-loop.php

    <? $excluded_roles = array ('administrator', 'author', 'subscriber'); // this can be any roles you have set up
    	if (bp_has_members( 'exclude=' . exclude_by_role($excluded_roles) . '&' . bp_ajax_querystring( 'members' ) ) ) : ?>
    

    Unfortunately, it still is not excluding any of the specified roles. I took a look at the second example, but not sure where to put the code. Any suggestions?

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