exclude_by_role function no longer working?
-
I am working with a clients site that uses exclude_by_role function to only show members who are subscribers in the member loop.
code in /mytheme/buddypress/members/members-loop.php
is as follows:
<?php do_action( 'bp_before_members_loop' ); ?> <?php $excluded_roles = array ('administrator', 'author', 'customer', 'editor', 'contributor', 'shop manager'); // this can be any roles you have set up if (bp_has_members( 'exclude=' . exclude_by_role($excluded_roles) . '&' . bp_ajax_querystring( 'members' ) ) ) : //if ( bp_has_members( bp_ajax_querystring( 'members' ) ) ) : ?>
the function itself is in
mytheme/functions.php
and is as follows:
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; }
this code has worked to exclude certain rolls from the member results but does not seem to be doing anything anymore. all members are returned regardless of their rolls now.
Please help if you can. it seems the code was also removed from github I am assuming because it is depreciated or something.
any thoughts?
- The topic ‘exclude_by_role function no longer working?’ is closed to new replies.