Hi @muskokee,
Will be faster for me to give you a tutorial.
– Create a template file, call it testing.php and add it at the root of your child-theme.
This file should contain a template name in header comment and some minimal html and condition to get a sidebar and a footer. The example comes also with a BP action hook.
– The template file
<?php
/*
Template Name: Testing
*/
get_header(); ?>
<div id="primary" class="site-content">
<div id="content" role="main">
<?php if( is_user_logged_in() ) {
echo'<h3>My test content title</h3>';
do_action( my_testing);
}?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar( 'front' ); ?>
<?php get_footer(); ?>
– Go to page dashboard, and create a new page. Call it Testing and asign in page attributes Testing as template. Save.
– Open bp-custom.php and copy/paste these functions.
First we setup the nav on profile with a sub-nav going to our test page.
function bpfr_post_profile_setup_nav() {
global $bp;
$parent_slug = 'testing';
$child_slug = 'testing_sub';
bp_core_new_nav_item( array(
'name' => __( 'Testing' ),
'slug' => $parent_slug,
'screen_function' => 'bpfr_profile_post_screen',
'position' => 40,
'default_subnav_slug' => $child_slug
) );
//Add subnav item
bp_core_new_subnav_item( array(
'name' => __( 'My Testing' ),
'slug' => $child_slug,
// this slug goes to profile/name/
//'parent_url' => $bp->loggedin_user->domain . $parent_slug.'/',
// this slug goes directly to a page
'parent_url' => $bp->root_domain .'/'. $parent_slug .'/',
'parent_slug' => $parent_slug,
'screen_function' => 'bpfr_profile_post_screen'
) );
}
function bpfr_profile_post_screen() {
add_action( 'bp_template_content', 'bpfr_profile_post_screen_content' );
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
}
// we took the opportunity to add an action hook. Can be usefull...
function bpfr_profile_post_screen_content() {
do_action( my_testing);
}
add_action( 'bp_setup_nav', 'bpfr_post_profile_setup_nav' );
– And because you’re testing, we’ll do a little test by inserting a text directly into the template.
function action_x() {
echo 'Test lorem ipsum, i can read this !';
}
add_action( 'my_testing', 'action_x' );
Now you can read the snippet, add you’re own html, loops and hooks to the template file, or simply publish something on the page… Hope you’ll understand how this is working. Happy testing !