I am ussing bbPress and want to extend the BBP_Shortcodes class in order to replace a function with my own.

Here is my basic snippet which seems to do nothing:

class WPTUMBLE_Shortcodes extends BBP_Shortcodes {

     * Display an index of all visible root level forums in an output buffer
     * and return to ensure that post/page contents are displayed first.
     * @since bbPress (r3031)
     * @param array $attr
     * @param string $content
     * @uses bbp_has_forums()
     * @uses get_template_part()
     * @return string
    public function display_forum_index() {

        echo 'Yo Adrian';


function wptumble_register_shortcodes() {
    global $bbp;

    // Bail if bbPress is not loaded
    if (is_a($bbp, 'bbPress')) return;

    $bbp->shortcodes = new WPTUMBLE_Shortcodes();

add_action( 'bbp_init', 'wptumble_register_shortcodes',    25  );

Looking at the bbpress functions setup it says:

add_action( 'bbp_init', 'bbp_register_shortcodes',    18  );

What am I missing?

*I have tried every priority from hooking to init at priority 1, all the way through where I posted above, but none seem to do anything.

Even stranger: I basically paste that code into a plugin file I called xyz and I receive no errors, just nothing happens when I view what should be outputted. Meaning I get the original output for display_forum_index() instead of my new one.

Here is where it gets even worse: Instead of simply creating a plugin with that code in it, I place the code into my 'full' plugin.

I use the following:

include_once (WPTUMBLE_PLUGIN_DIR.'twentyeleven-bbpress-child/inc/tumble-core-shortcodes-single.php');

I then have the WPTUMBLE_Shortcodes class pasted into the file above. *Trying to keep things clean so separating my different functions into different files in my custom plugin

What happens is when I do that I end up with a fatal error saying BBP_Shortcodes is not defined.

The ONLY difference is I am putting the code into a file that is include_once..

What in the world could be going on there?

Either I get nothing happening when it's a single plugin file, or I get fatal error if I include_once and place the code in another file.

Soooo confused now.

1 Answer 1


I can't tell you what you're doing wrong with your includes and such, but your method of extending the class is basically correct.

However, the most likely scenario that I can see is that your add_action is basically executing in the wrong place. Also, you're doing-it-wrong by allowing the original action to stand instead of replacing it.

Try this:

function wptumble_actions_modification() {
  remove_action('bbp_init', 'bbp_register_shortcodes', 18);
  add_action('bbp_init', 'wptumble_register_shortcodes', 18);

This removes the original action and replaces it with your own, and it does it at the plugins loaded hook, ensuring that it happens after both your plugin and the bbPress plugin is loaded, and presumably all the action hooks for bbPress were in place, but not yet executed (since init hasn't been reached).

  • Thanks Otto, this actually made more headway than where I was before. I had to change the hook to bbp_loaded instead of bbp_plugins_loaded in order to get it to fire. Now I am able to get the content removed, but receive a blank area instead of the extended class kicking in. Just in case you use bbpress, I created a quick plugin showing exactly what I was after. dl.dropbox.com/u/2045194/xyz-bbpress.php I am replacing a number of the class functions with my own modifications. Am I on the right track? Thnx so much for your time, I know how valuable it is.
    – shawn
    Nov 23, 2011 at 11:09
  • btw, wanted to say I really enjoyed meeting you and Nacin in Seattle. It was really cool of you guys to stop by like that. Well if anything it shows I am persistent as I am still working on the same issue I mentioned back at the bar a few months back. LOL At least I am getting closer, wish bbpress was easier to work with but I am learning a lot.
    – shawn
    Nov 23, 2011 at 11:55
  • Thanks Otto, got it working just fine now. Have a great thanksgiving day off
    – shawn
    Nov 24, 2011 at 1:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.