Skip to:
Content

BuddyPress.org

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#6434 closed defect (bug) (no action required)

BuddyPress $bp->groups->slug Bug?

Reported by: dunhakdis's profile dunhakdis Owned by:
Milestone: Priority: high
Severity: major Version: 2.2.3
Component: Groups Keywords:
Cc:

Description

Hello!

So I am developing and updating a BuddyPress theme and I have the latest version of BuddyPress installed. I changed my groups page slug into 'community'.

Now I have a custom link which is directly linked into groups page using $bp->groups->slug. When I visit that page, it returns 404 error.

After investigating, I tried to echo the returned value of $bp->groups->slug and then I realised that the groups slug were not updated from 'groups' to 'community' at all.

So what I did is I manually get the selected page for buddypress groups and now it's working.

Here is the code:

<?php $bp_pages = get_option('bp-pages'); ?>
<?php $bp_groups_page = get_post($bp_pages['groups']); ?>
<?php $bp_groups_page_slug = $bp_groups_page->post_name; ?>

I would like to confirm is this is a bug or my fault? I have $bp->groups->slug outside bp loop.

Thank you so much!

Change History (2)

#1 @boonebgorges
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Hi dunhakdis - Thanks for the report.

The Groups component (and most BP components) have two different concepts of "slug". One is the "root slug". This is what is determined by the slug of the Groups directory page (Dashboard > Pages), and it's the slug used when building URLs where the component slug directly follows the site URL. So, on a site example.com, buddypress()->groups->root_slug is used to build URLs like the following:

  • example.com/groups/
  • example.com/groups/my-cool-group/

buddypress()->groups->slug is the other kind of slug (the non-"root" slug). This is used primarily to build URLs where the slug appears later in the URL. Eg: example.com/members/boone/groups/. By default, this slug is not affected by the post_name of the Groups directory page.

It sounds like, in your case, you should be using the root_slug. (Or better yet - if you're linking into a specific group, use bp_get_group_permalink( $group_object ) to get a full group URL.)

I'm going to close this ticket as invalid, but if I've misunderstood your intent, please feel free to follow up.

#2 @dunhakdis
9 years ago

Alryt my bad. So what I am doing is I am calling for the groups' root slug which I should not be doing since I want the 'non-root' slug. I'll try buddypress()->groups->slug instead.

Thanks Boone!

Note: See TracTickets for help on using tickets.