Skip to:

bbp_has_topics – hide topics from private grou

  • m1000



    I display recent topics on the frontpage using bbp_has_topics. I would like to hide topics of private groups for non-members of group. How to do it?

Viewing 11 replies - 1 through 11 (of 11 total)
  • You should be able to wrap your bbp_has_topics output in a conditional like:

    if ( bp_group_is_visible() ) {
    //do the topics loop here

    bp_group_is_visible checks to see if the group is public or private, and if it’s public, returns true. If not public, then it checks to see if the user is a member of the current group; if yes, it returns true. It’s located at /bp-groups/bp-groups-template.php -> line 377.

    function bp_group_is_visible( $group = false ) {
     378      global $groups_template;
     380      if ( bp_current_user_can( 'bp_moderate' ) )
     381          return true;
     383      if ( empty( $group ) )
     384          $group =& $groups_template->group;
     386      if ( 'public' == $group->status ) {
     387          return true;
     388      } else {
     389          if ( groups_is_user_member( bp_loggedin_user_id(), $group->id ) ) {
     390              return true;
     391          }
     392      }
     394      return false;
     395  }



    i tried using the code you provided but nothing i tried worked… the latest forum topic is a widget so i tried putting it around the widget but that of course didnt work…

    so i dug deeper and found the template for the actual link and wrapped the code around that and it didnt work either 🙁

    the widget code:

    the mytopics code:

    the single topic code where i put the code you provided:

    not sure where else to put it…

    any help would be appreciated, thanks!

    When you say it didn’t work, do you mean that people who should see the topics couldn’t, or that no one could see the topics, or that everyone could see the topics? Was it too generous in letting people through or did it keep everyone out? 😉

    Also, could it be that this is this being used in a sidebar? I’m wondering if the placement on the page means that the group context is not certain, so you’d need to pass the group_id into bp_group_is_visible. Although I’d expect the bbp_topics to need to access the group_id as well.



    it doesnt work as in: no posts show up at all :/

    it is on the sidebar… how would i pass the group_id and give bbp_topics access… pretty much a noob here, sorry…

    thanks in advance!

    Put this before the code we’ve been talking about, and see what it displays on the page:

    $test_id = bp_get_current_group_id();
    echo 'The current group ID is:' . $test_id;

    If it returns a number besides zero (zero means that it can’t figure out which group is the current group, a non-zero number is the current group ID), then you could probably adjust the conditional code:

    if ( bp_group_is_visible( bp_get_current_group_id() ) ) {
    //do the topics loop here

    Fingers crossed.



    it shows a zero 🙁

    That’s too bad. A couple of questions I should have asked at the beginning:

    1. What theme are you using?
    2. If you remove the conditional we added, does bbPress return topics for the correct group?



    i’m using a premium theme, cinimatix…

    if i remove the “if bp_group_is_visible” conditional it works fine but shows all topics… i didnt try the second conditional bc its not even reading the group id..



    Sorry, I think I misunderstood your question from the beginning. You’re not trying to display topics on the front page of a group. You’re trying to show topics on the site’s front page? If so, what I’ve talked about won’t help at all. 🙁

    In looking into bbPress, I can’t really see how a particular forum is associated with a group. So I’m afraid I’m not going to be much help. Maybe someone else knows more about bbPress’s group forum integration?



    aha not front page but site wide sidebar… its ok, thanks for trying tho…

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘bbp_has_topics – hide topics from private grou’ is closed to new replies.
Skip to toolbar