This topic has 3 replies, 2 voices, and was last updated 9 years by Parkproductions.

  • Author
  • #41075
     Parkproductions
    Participant

    Hi there, I’ve created moderator accounts for each group on our network (approx 50 accounts) I will assign them the role of moderator, however I want to hide the accounts from the membership page so new users aren’t put off by all of the moderator accounts showing up.

    I’ve tried the following code in the membersloop page but it has had no effect.

    <?php while ( bp_members() ) : bp_the_member(); $user = new WP_User( bp_get_member_user_id() );
    if ( $user->roles[0] != ‘moderator’ ) :
    ?>

    #41203
     sharmstr
    Moderator

    I haven’t tried your code, so not sure if it even works, but my first thought is did you change the correct file? It should be the one in themes/kleo not the one in plugins/buddypress. Furthermore, it should be copied to your child theme so it doesnt get blasted during upgrades. Let me know.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #41205
     sharmstr
    Moderator

    Are you talking about forum roles? That’s the only standard ‘moderator’ role. If so, I think its in the db as “bbp_moderator”.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #41224
     Parkproductions
    Participant

    Yeah moderator was not the right role to use for the accounts I wanted hidden, I just changed them to administrators (The accounts were setup to post content in each sport group) and used the following code to hide them from the members list added to functions.php

    function get_user_ids_by_role($role){
    $users=array();
    $founded_users = get_users( array( ‘role’ => $role ) );
    if(!empty($founded_users)){
    foreach((array)$founded_users as $user)
    $users[]=$user->ID;
    }

    return $users;
    }

    function exclude_by_role( $exclude_roles, $implode = true ) {
    $memberArray = array();
    foreach ( $exclude_roles as $exclude_role ) {
    $memberArray = array_merge($memberArray, get_user_ids_by_role($exclude_role) );
    }

    if( !$implode )
    return $memberArray;

    $theExcludeString = implode( “,”, $memberArray );
    return $theExcludeString;
    }

    add_action(‘bp_ajax_querystring’,’bp_exclude_byroles’,20, 2);
    function bp_exclude_byroles($qs=false,$object=false){

    if($object!=’members’) //hide for members only
    return $qs;

    $args = wp_parse_args($qs);
    //check if we are searching for friends list etc?, do not exclude in this case
    if(!empty($args[‘user_id’]))
    return $qs;

    $excluded_roles = array( ‘administrator’ ); // you can add roles here
    $exclude = exclude_by_role( $excluded_roles );

    if(!empty($args[‘exclude’]))
    $args[‘exclude’]=$args[‘exclude’].’,’.$exclude;
    else
    $args[‘exclude’] = $exclude;

    $qs = build_query($args);
    return $qs;
    }

Viewing 4 posts - 1 through 4 (of 4 total)

The forum ‘KLEO’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?