Skip to:
Content

BuddyPress.org

Opened 9 years ago

Closed 9 years ago

#7025 closed enhancement (fixed)

Introduce a method for getting a component's page_id

Reported by: garrett-eclipse's profile garrett-eclipse Owned by: boonebgorges's profile boonebgorges
Milestone: 2.6 Priority: normal
Severity: normal Version: 2.5.0
Component: Core Keywords: needs-patch good-first-bug
Cc:

Description

Hello,

I'd like to request a method which takes a component slug and returns the page_id associated.

Something like this would suffice, having it default to use bp_current_component if slug isn't provided.

<?php
/**
 * Get the page ID associated with component slug
 *
 * @since 1.0.0
 *
 * @param string $component The slug representing the component.
 * @return int The page_id associated with the component.
 */
function components_get_page_id( $component = NULL ) {
        if ( empty( $component ) ) {
                $component = bp_current_component();
        }
        $bp_pages = get_option( 'bp-pages' );
        if ( empty( $bp_pages ) {
                return false;
        }
        return $bp_pages[$component];
}

Much appreciated,
Cheers

Change History (4)

#1 @DJPaul
9 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

#2 @DJPaul
9 years ago

  • Keywords good-first-bug added

#3 @boonebgorges
9 years ago

  • Milestone changed from Future Release to 2.6

#4 @boonebgorges
9 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 10755:

Introduce bp_core_get_directory_page_id().

This convenience function provides a way for developers to get the ID of a WP
page corresponding to a BuddyPress component.

Props garrett-eclipse.
Fixes #7025.

Note: See TracTickets for help on using tickets.