Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to Exclude a Group From the Groups Loop

  • @pollyplummer

    Member

    Is there any way to exclude a group from the loop? I don’t see anything in the documentation. I can’t make it hidden or private because I’m using the group as a shell for a global forum. (Each member is automatically added to this group at registration) … so it’s always floating to the top as the most popular group since it has the most members. I tried using &exclude= and it doesn’t do anything. Any help is appreciated. Thanks!

Viewing 12 replies - 1 through 12 (of 12 total)
  • @nahummadrid

    Participant

    @pollyplummer r-a-y showed me how to do this for blogs, thought i’d flip it for the groups loop and it seems to work. this was from a couple versions back there may be something new as it was said there would be an easier exclude parameter for has_blogs but i haven’t seen it. anyway try

    php while ( bp_groups() ) : bp_the_group(); if(bp_get_group_name() != “Name of your Group”) :

    then add the ?php endif? before the endwhile.

    @pollyplummer

    Member

    Thanks @nahummadrid ! This works:

    while ( bp_groups() ) : bp_the_group(); if(bp_get_group_name() != ‘MyGroup’ ) :

    I think I’ll post something about this on wpmu.org because it seems like a pretty common request. I wish there was some kind of exclude parameter instead. ;)

    @ch8rt

    Member

    I’m totally up on my php so could someone help with converting this into an ‘if’ ‘else’ statement that allows for multiple group names rather than just one.

    So far I’ve got this
    if(bp_get_group_name() != ‘Community’ ) : if(bp_get_group_name() != ‘General’ ) : if(bp_get_group_name() != ‘Off Topic’ ) :

    but I need to endif 3 times which surely isn’t the best way. And also I can get an else in there.

    To put some context around this, I plan on having a number of groups for forums only, and new members will automatically be added to them, so I plan on hiding the item-header and nav section on these group pages and show a new

    in there instead. Then when they are removed from the groups page and widgets they’ll only be accessible through the forums. :)

    @hnla

    Participant

    You need ‘||’ ‘Or’ don’t you?

    so you want to run code if it’s not the community group or not the general group etc?

    if(bp_get_group_name() != ‘Community’ || bp_get_group_name() != ‘General’ ):

    @rogercoathup

    Participant

    @ch8rt – rather than write that long nested if structure, put your group names into an array, and then check if the bp_get_group_name is in that array, using the PHP in_array() function: http://php.net/manual/en/function.in-array.php

    @pollyplummer – Yes, an exclude parameter would be very useful – it came up in another forum thread recently as well

    @boonebgorges

    Keymaster

    I have grand designs of adding things like exclude parameters to all the bp_has_x loops. Now that the 1.2 branch has been merged into the trunk, I can have a swing at those designs :)

    @ch8rt

    Member

    I’m still trying to get this working, an array seems the best way, like you said, but I have no idea on how to code it properly. The documentation for php always seems to go over my head.

    This is what I have so far.

    `<?php
    $special = array(“General”, “Community”);
    if ( bp_get_group_name() == $special ) ?>
    /*special group*/

    /*none special group*/
    `

    But thats not working. Any ideas?

    @hnla

    Participant

    Where’s your in_array() ?

    @hnla

    Participant

    PHP docs are fairly clear, but try this:

    `$special = array(“General”, “Community”);
    if (in_array( bp_get_group_name(), $special) ) : ?>

    Do stuff if group name is in array

    Otherwise do some different stuff

    `

    @ch8rt

    Member

    Yep, works a charm. Big Thanks.

    I wasn’t getting anything with the in_array (must’ve had brackets in the wrong place or something) and then started thinking that the array call in the function up top would do that bit?

    Again, thanks.

    @volpv

    Member

    Hi @boonebgorges can we specify the exclude bp_has_group parameters in widget_logic for excluding some groups from getting displayed?

    Appreciate your help. Thank you

    @number_6

    Participant

    I need to get this done, and this conversation perplexes me a little.

    First of all I don’t know which file I’ll need to “say” this in. Is it the bp-custom.php file?

    And second of all, Hugo’s php doesn’t appear to me to contain any directions on what to do with the groups after “summoning” them. What else do I need to “say”?

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘How to Exclude a Group From the Groups Loop’ is closed to new replies.
Skip to toolbar