Create a default component slug from a WP page root_slug.


(string) bp_core_component_slug_from_root_slug( (string) $root_slug ); 

Since 1.5, BP components get their root_slug (the slug used immediately following the root domain) from the slug of a corresponding WP page.

E.g. if your BP installation at example.com has its members page at example.com/community/people, $bp->members->root_slug will be 'community/people'.

By default, this function creates a shorter version of the root_slug for use elsewhere in the URL, by returning the content after the final / in the root_slug ('people' in the example above).

Filter on bp_core_component_slug_from_root_slug to override this method in general, or define a specific component slug constant (e.g. BP_MEMBERS_SLUG) to override specific component slugs.

Returns (string)

The short slug for use in the middle of URLs.

Parameters (1)

0. $root_slug (string)
The root slug, which comes from $bp->pages->[component]->slug.


  1. if ( !function_exists( 'bp_core_component_slug_from_root_slug' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-functions.php'; 
  4. // The root slug, which comes from $bp->pages->[component]->slug. 
  5. $root_slug = ''; 
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_core_component_slug_from_root_slug($root_slug); 

Defined (1)

The function is defined in the following location(s).

  1. function bp_core_component_slug_from_root_slug( $root_slug ) { 
  2. $slug_chunks = explode( '/', $root_slug ); 
  3. $slug = array_pop( $slug_chunks ); 
  5. /** 
  6. * Filters the default component slug from a WP page root_slug. 
  7. * @since 1.5.0 
  8. * @param string $slug Short slug for use in the middle of URLs. 
  9. * @param string $root_slug The root slug which comes from $bp->pages-[component]->slug. 
  10. */