I can’t figure out what is going on.
That snippet is 6 years old. BuddyPress is slightly different today.
Some explanation here:
bp_is_current_component
bp_current_action
May be you can also read here:
Template Overload from a Plugin
@danbp : Thank You very much for your reply.
Even I’ve tried bp_current_component()
and bp_is_current_component()
functions with no success.
Actually this function works fine when used in default buddypress pages like domain/activity/
. This returns me “activity”, which is exactly correct. But when I tried this in my custom page (domain/custompage
), I’m getting an empty string.
Can you give details about what you’re trying to build ?
Add custom page dynamically is not enought.
In buddypress, activity, members, group have a definite pages like ‘domain/activity’, ‘domain/members’, ‘domain/group’, respectively. Likewise I’m trying to create my own custom page like ‘domain/mycustom’.
For this purpose I referred John James Jacoby’s Post in here. The snippet used in that link didn’t work for me. I don’t know where I’m missing.
From that snippet, I found that $bp->current_component
returns me an empty string.
Sorry the link is Link. My mistake
https://buddypress.org/support/topic/make-your-own-custom-buddypress-page/.
The snippet I found in the above link is as below:
define('BP_EXAMPLE_SLUG', 'fun');
function bp_show_example_page() {
global $bp, $current_blog;
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( 'fun', true );
}
}
add_action( 'wp', 'bp_show_example_page', 2 );