Title: [Plugin: Events Manager] Sub nav creation on Events navigation (Buddypress)
Last modified: August 20, 2016

---

# [Plugin: Events Manager] Sub nav creation on Events navigation (Buddypress)

 *  Resolved [petet_uk](https://wordpress.org/support/users/petet_uk/)
 * (@petet_uk)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/plugin-events-manager-1/)
 * Hi all,
 * I’ve created a new Sub nav item for the Events Manager, but I have had to hardcode
   the events slug and parent link because the $bp object doesn’t seem to have the
   events object in when I run the code.
 * I would much rather be creating the events slug by below line of code, but $bp-
   >events doesn’t exist at the point of running the action.
 * $events_slug = $bp->events->slug
 * Could anyone tell me what action I should be tying the sub menu creation in to.
 * See below for my current version.
 * _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome#Posting_Code).
   Please use the [pastebin](http://wordpress.pastebin.com/)]_
 * Thanks in advance

Viewing 8 replies - 1 through 8 (of 8 total)

 *  [agelonwl](https://wordpress.org/support/users/angelonwl/)
 * (@angelonwl)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/plugin-events-manager-1/#post-2166537)
 * did try putting it into global?
 * `global $bp;`
 *  Thread Starter [petet_uk](https://wordpress.org/support/users/petet_uk/)
 * (@petet_uk)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/plugin-events-manager-1/#post-2166560)
 * Update from the moderation, code can be found at [http://pastebin.com/BM8adpdH](http://pastebin.com/BM8adpdH)
 * The events object is created as a child of the global $bp, but I think somehow
   my code above is being run before the the events object is created. Therefore,
   I don’t think I’m tying it to the right action.
 *  [agelonwl](https://wordpress.org/support/users/angelonwl/)
 * (@angelonwl)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/plugin-events-manager-1/#post-2166569)
 * can you try this forum? [http://wordpress.org/support/topic/determine-if-single-or-list-event-in-template?replies=3](http://wordpress.org/support/topic/determine-if-single-or-list-event-in-template?replies=3)
 * so that you check first if the event object is loaded before you execute your
   code AND also why does at line 12 of [http://pastebin.com/BM8adpdH](http://pastebin.com/BM8adpdH)
   or the `do_action( 'my_invites_setup_nav' );` is inside the function?
 *  Thread Starter [petet_uk](https://wordpress.org/support/users/petet_uk/)
 * (@petet_uk)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/plugin-events-manager-1/#post-2166584)
 * Thanks for that. It’s hitting the final else clause, which confirms that the 
   events object hasn’t yet been created.
    do_action on line 12 has been removed,
   but it was an idle line anyway.
 * The code is being run before the events plugin is initialised, and therefore 
   I need to somehow run it after.
 *  [Marcus (aka @msykes)](https://wordpress.org/support/users/netweblogic/)
 * (@netweblogic)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/plugin-events-manager-1/#post-2166749)
 * make sure your code is run after the action that sets up the navigation menus.
   probably just requires adding a priority number to add_action
 *  Thread Starter [petet_uk](https://wordpress.org/support/users/petet_uk/)
 * (@petet_uk)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/plugin-events-manager-1/#post-2166753)
 * Hi Marcus,
 * Thanks, I’ve tried that by adding a priority of 12 and it didn’t have any effect.
   Also tried it with priority 100 with no difference.
    I’m using var_dump($bp->
   events); to see the contents of the object, just to prove it exists, but nothing
   is outputted because it still hasn’t created the events object, even with a priority
   of 100 on the bp_setup_nav action.
 * `add_action( 'bp_setup_nav', 'my_invites_setup_nav', 100 );`
 * If you’ve got any other suggestions, I would really appreciate them because I’m
   at a bit of a loss as to why it’s being run before the $bp->events object is 
   created.
 *  [Marcus (aka @msykes)](https://wordpress.org/support/users/netweblogic/)
 * (@netweblogic)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/plugin-events-manager-1/#post-2166760)
 * if your plugin is adding stuff that EM overwrites, the solution is to make sure
   you’re loading this after EM has done it’s stuff.
 * bp stuff is added to EM after plugins_loaded so that BP is definitely there, 
   make sure whatever you’re running is after that too (as well as after our function
   to set up the navs).
 * you could also try modifying the do_action filter to output actions as it goes
   to see what’s going wrong on your code
 *  Thread Starter [petet_uk](https://wordpress.org/support/users/petet_uk/)
 * (@petet_uk)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/plugin-events-manager-1/#post-2166979)
 * I eventually fixed this by hooking my function into the wp_loaded action.
    My
   first problem was that I had my code running from mu-plugins, which runs before
   events manager and therefore it couldn’t find it.
 * I move the code into functions.php and then added it to the wp_loaded action.
 * Thanks for your help Marcus.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘[Plugin: Events Manager] Sub nav creation on Events navigation (Buddypress)’
is closed to new replies.

 * 8 replies
 * 3 participants
 * Last reply from: [petet_uk](https://wordpress.org/support/users/petet_uk/)
 * Last activity: [14 years, 8 months ago](https://wordpress.org/support/topic/plugin-events-manager-1/#post-2166979)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
