Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Creating a root component with Skeleton Component

Ok so I think I figured this out. I used the Skeleton component to do this and you need to change a couple of things in order for it to work. First of all, the component registers itself too late so bp_core_add_root_component() won’t work.

Change line 45 of loader.php to
add_action( ‘bp_include’, ‘bp_example_init’ );

This will register the component before Buddypress sets up the URI:s and thus giving you a chance of adding your own root component.
Then for registering my own root component I did this:
function bp_example_setup_root_component() {
/* Register ‘example’ as a root component */
bp_core_add_root_component( BP_EXAMPLE_SLUG );
}
add_action( ‘bp_setup_root_components’, ‘bp_example_setup_root_component’ );

Lastly you need to setup your own screen functions. Following BP:s way of doing things I created
function bp_example_screen_example() {
global $bp, $wpdb;
if ( $bp->current_component != BP_EXAMPLE_SLUG )
return false;
die(“Example screen!”);
}
add_action( ‘wp’, ‘bp_example_screen_example’, 3 );

Now that last function will catch everything that arrives on the example slug so you probably want to make it more picky so to speak.

Skip to toolbar