Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to use the example code found at http://codex.buddypress.org/developer-docs/group-extension-api/ to use in a plugin, but when I try to use it I keep getting the following error:

Fatal error: Class 'BP_Group_Extension' not found in /home/httpd/html/wearewomenmarch.net/public_html/wp-content/plugins/buddypress-group-documents/index.php on line 53

The line 53 in question is as follows:

class BP_Group_Document_List_Extension extends BP_Group_Extension {  

And the whole chunk of code I'm trying to use is

class BP_Group_Document_List_Extension extends BP_Group_Extension {  
var $visibility = 'private';
var $enable_create_step = false;
var $enable_nav_item = false;
var $enable_edit_item = false;

function bp_group_document_list_extension() {
        $this->name = 'Documents List';
        $this->slug = 'group-document-list';

        $this->create_step_position = 21;
        $this->nav_item_position = 31;
    }

    function create_screen() { }

    function create_screen_save() { }

    function edit_screen() {  }

    function edit_screen_save() { }

    function display() {
        display_group_document_list();
    }

    function widget_display() {  }
}
bp_register_group_extension( 'BP_Group_Document_List_Extension' );

Groups are active on the site, and the BP Group Calendar plugin is active. I see it uses the Group Extension API as well and it works, so I'm sure I'm making some mistake. I'd appreciate any advice on where to go from here so I can resolve that fatal error.

share|improve this question
add comment

1 Answer

You can get this fatal error if you plugin is loaded before BuddyPress, if you're creating extension for BuddyPress, first you should check if BuddyPress is active and loaded, here is suggested method from BP Codex.

/*
Plugin Name: My Plugin
Plugin URI: http://example.org/my-plugin/
Description: My BuddyPress plugin
Version: 1.0
Requires at least: WordPress 2.9.1 / BuddyPress 1.2
Tested up to: WordPress 2.9.1 / BuddyPress 1.2
License: GNU/GPL 2
Author: Some Person
Author URI: http://example.org/me/
*/

/* Only load code that needs BuddyPress to run once BP is loaded and initialized. */
function my_plugin_init() {
    require( dirname( __FILE__ ) . '/my-plugin.php' );
}
add_action( 'bp_include', 'my_plugin_init' );

/* If you have code that does not need BuddyPress to run, then add it here. */

Source: Checking For BuddyPress

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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