Skip to:
Content
Pages
Categories
Search
Top
Bottom

Problems with $bp->current_component – Am I doing something wrong?

  • Avatar of John Blackbourn
    John Blackbourn
    Participant

    @johnbillion

    In writing a custom component for BuddyPress I need to determine whether the user is on any page within the Groups section of the site.

    The problem is that $bp->current_component == 'groups' returns true if the user is on the Groups page of a user’s profile too (eg on /members/[username]/groups/ ).

    How can I differentiate between the Groups section of the site and a Groups page in a user’s profile?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Avatar of Burt Adsit
    Burt Adsit
    Participant

    @burtadsit

    if ($bp->current_component == $bp->groups->slug && $bp->is_single_item){}

    Is how I detect if the user is in a group page in the member theme. Such as: /groups/cats

    if ( $bp->current_component == $bp->groups->slug && empty( $bp->current_action ) ) {}

    Is how I detect is the user is in a group directory. The group directory doesn’t have anything after /groups. There’s no ‘action’ to detect.

    If you take a look at bp-groups.php groups_setup_nav() you’ll see all the stuff bp sets when a user vists one of their groups.

    Avatar of thebloghouse
    thebloghouse
    Participant

    @thebloghouse

    Thanks for this Burt – was exactly what I was looking for!

    Avatar of John Blackbourn
    John Blackbourn
    Participant

    @johnbillion

    I forgot to thank you for this Burt. Worked a treat. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Problems with $bp->current_component – Am I doing something wrong?’ is closed to new replies.