Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] How to get group id while in activity-loop.php

  • @zlamczyk

    Participant

    Running…
    WP 2.9.2
    BP 1.2.3

    I want to place static content on an individual groups home page. Ideally, I’d like to simply disable the activity stream from the admin menu and then implement this, but I’ve realized that the easiest thing to do would be to simply enable activity streams and then modify my BuddyPress theme’s activity-loop.php file to display the corresponding group’s static home page. But, to do this, I would need to be able to distinguish between each group – I assume by group id. How do I retrieve the group id to a variable? Is it as simple as created a global bp and then using $bp->group->id?

Viewing 6 replies - 1 through 6 (of 6 total)
  • @nuprn1

    Participant

    $bp->groups->current_group->id would be the actual group_id for the group you are viewing (within the group component)

    Now if you needed the group_id from an activity record, then the item_id contains the group_id (whereas the component is $bp->group->id )

    @boonebgorges

    Keymaster

    If you just want to display static content on the group’s home page in place of the activity stream, I wouldn’t go hacking activity-loop.php (it’s too far upstream, so to speak). In [your-theme]/groups/single/home.php, there’s a string of conditionals starting around line 28. Play with them to get what you want.

    As for the current group id, you can get that from bp_get_group_id() when inside the bp_has_groups() loop.

    @zlamczyk

    Participant

    My theme does not have a groups directory – so no home.php there. There is a home.php here:
    root/wp-content/plugins/buddypress/bp-themes/bp-default/single/
    Is it possible that my theme simply inherits this file?

    @zlamczyk

    Participant

    @boonebgorges I successfully modified the “*/bp-default/single/home.php” so that static content was placed in the home page section of the individual group page. I also managed to collect the current group id! Your advice was spot-on (once I located the inherited home.php file, anyway, haha)!

    @boonebgorges

    Keymaster

    Awesome, glad it works!

    It’s best to make your changes in a child theme rather than in bp-default. Just copy the file from bp-default into your theme file and edit it there, and it’ll override the default theme file. Make sure you respect the directory structure; groups/home.php has to go in a folder called groups in your child theme or it won’t be recognized.

    @k9disc

    Participant

    I’d like to do this… checking it out now but no idea what to look for…
    Any help would be appreciated.
    Peace,
    Ron

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] How to get group id while in activity-loop.php’ is closed to new replies.
Skip to toolbar