$bp is empty after using bp-custom.php when trying to create a new custom page
-
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
- The topic ‘$bp is empty after using bp-custom.php when trying to create a new custom page’ is closed to new replies.