Skip to:
Content
Pages
Categories
Search
Top
Bottom

$bp is empty after using bp-custom.php when trying to create a new custom page


  • shaisimchi
    Participant

    @shaisimchi

    Hi,

    I have added the following into bp-custom.php under wp-content/plugins

    . I found this solution in under:

    http://buddypress.org/forums/topic/make-your-own-custom-buddypress-page

    define(‘BP_EXAMPLE_SLUG’, ‘example’);

    function example_page_setup_root_component()

    {

    bp_core_add_root_component( BP_EXAMPLE_SLUG );

    }

    add_action( ‘plugins_loaded’, ‘example_page_setup_root_component’, 2 );

    function bp_show_example_page() {

    global $bp, $current_blog, $wpdb;

    if ( $bp->current_component == BP_EXAMPLE_SLUG && $bp->current_action == ” ) {

    // The first variable here must match the name of your template file below

    bp_core_load_template( ‘example’, true );

    }

    }

    add_action( ‘wp’, ‘bp_show_example_page’, 2 );

    also i put the file example.php under themes/bp-sn-parent which contains:

    <?php get_header(); ?>

    <?php if (empty($bp)) :?>

    <?php echo ‘shit’?>

    <?php else:?>

    <h3><?php echo $bp->loggedin_user->domain; ?></h3>

    <?php endif;?>

    <p><?php echo $bp->displayed_user->domain; ?></p>

    <?php get_footer(); ?>

    per the file below it seems that $bp is empty. any idea?

    per my understanding bp-custom.php is loaded before anything else? does that mean before $bp is created?

    any way for me to get $bp to work there?

    Thanks,

    Shai

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

  • r-a-y
    Keymaster

    @r-a-y

    You need to call $bp before you can actually do anything with it.

    Before calling $bp, add:

    global $bp;

    Btw, it looks like you’re either using an older version of BP or you’re using the BP Classic theme.

    You should make any external changes in a child theme when possible.


    shaisimchi
    Participant

    @shaisimchi

    thanks @r-a-y!!!

    this seems to solve some of my problem.

    still what i am doing is loading this new custom page while viewing another profile.

    so on the left hand side under me i can see my avatar and all the nav options but for the user i am looking at i can see all the nav options but not the avatar and name.

    it seems that $bp->bp_options_avatar and $bp->bp_options_title are both empty so once again i suspect $bp is empty but on a different component of the screen.

    anything i am doing wrong here?

    Thanks for your help.

    Shai

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘$bp is empty after using bp-custom.php when trying to create a new custom page’ is closed to new replies.
Skip to toolbar