bp_is_component_front_page( string $component = '' )

Check if the specified BuddyPress component directory is set to be the front page.

Description

Corresponds to the setting in wp-admin’s Settings > Reading screen.

Parameters

$component

(Optional) Name of the component to check for. Default: current component.

Default value: ''

Return

(bool) True if the specified component is set to be the site's front page, otherwise false.

Source

File: bp-core/bp-core-template.php

2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
function bp_is_component_front_page( $component = '' ) {
    global $current_blog;
 
    $bp = buddypress();
 
    // Default to the current component if none is passed.
    if ( empty( $component ) ) {
        $component = bp_current_component();
    }
 
    // Get the path for the current blog/site.
    $path = is_main_site()
        ? bp_core_get_site_path()
        : $current_blog->path;
 
    // Get the front page variables.
    $show_on_front = get_option( 'show_on_front' );
    $page_on_front = get_option( 'page_on_front' );
 
    if ( ( 'page' !== $show_on_front ) || empty( $component ) || empty( $bp->pages->{$component} ) || ( $_SERVER['REQUEST_URI'] !== $path ) ) {
        return false;
    }
 
    /**
     * Filters whether or not the specified BuddyPress component directory is set to be the front page.
     *
     * @since BuddyPress 1.5.0
     *
     * @param bool   $value     Whether or not the specified component directory is set as front page.
     * @param string $component Current component being checked.
     */
    return (bool) apply_filters( 'bp_is_component_front_page', ( $bp->pages->{$component}->id == $page_on_front ), $component );
}

Changelog

Changelog
Version Description
BuddyPress 1.5.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.