Try not to repeat all the file path. Just putting:
themes/your-theme/buddypress/members/single/member-header.php
Sorry, I misunderstood. I’m not sure if the above example would work in a plugin directory.
add_action('get_template_part_members/single/member-header', 'add_member_header_stack', 10, 2);
add_action('bp_locate_template', 'remove_member_header_stack', 10, 6);
function add_member_header_stack($slug, $name) {
add_filter( 'bp_get_template_stack', 'my_custom_stack' );
}
function remove_member_header_stack($located, $template_name, $template_names, $template_locations, $load, $require_once) {
if("members/single/member-header.php" == $template_name) {
remove_filter( 'bp_get_template_stack', 'my_custom_stack' );
}
}
function my_custom_stack( $stacks = array() ) {
$retval = array();
$retval[] = '/path/to/plugin';
foreach ($stacks as $stack) {
$retval[] = $stack;
}
return $retval;
}
This is the best way to do this in my opinion.
Also just adding your stack would work, but I added conditions to only apply this filter when needed and remove after. Not sure how much resource it will save but just tried to be fancy.
To understand what this function filter does, I suggest reading this codex
Would I have to do any modifications on your code, and the plugin structure will be like:
my-plugin/buddypress/members/single/member-header.php
??
Thanks for the help 🙂
modification goes here $retval[] = '/path/to/plugin';
and yes, you have to have structure like that
And it will be like pluginfolder/pluginfile.php
? Or something else?