I am creating my own subnav menu by looping over the bp_options_nav object inside the $bp global.
something along the lines of:
$subnavs = $bp->bp_options_nav[$parent];
I then check if user has access to it and if they do output it like this:
foreach ($subnavs as $item)
{
if ($item['user_has_access'])
{
// my output code
}
}
This works great when I add it directly into a template file like profile.php but I don’t want to have it copied into every file, I want it to be centralised.
When I call my code on the template from a class like so:
mynamespacebudddyhelp::my_function('profile');
The $bp global now only shows I have access to public subnavs.
Inside my function I have tried doing:
global $bp
and
$bp = buddypress();
But its same story either way. I read that I shouldn’t pass the $bp object as a reference parameter but I am a bit confused here. It seems to be changing values based on scope. I am not sure how that is happening.
How can I get the correct values of the $bp global inside my helper function?