Skip to:
Content
Pages
Categories
Search
Top
Bottom

Class 'BP_Group_Extension' not found Installing Plugin

  • Avatar of Sclough
    sclough
    Participant

    @sclough

    I wrote a plugin to extend group information based on the documentation here: http://codex.buddypress.org/developer-docs/group-extension-api/ . The problem is that when I try to activate the plugin in WordPress I get “Class ‘BP_Group_Extension’ not found”. Yes, I’m on BuddyPress 1.1.3 so it is there. Apparently the class is just not loaded normally. Is there some kind of syntax to make sure that the class is loaded that should be at the top of my plugin? I tried wrapping the class declaraion in “if (class_exists(” and that removed the error, but I also wonder if it’s ever getting loaded because I don’t see any changes on the Group edit screens…

Viewing 7 replies - 1 through 7 (of 7 total)
  • Probably your plugin is getting loaded before BuddyPress is.

    I’m not even sure this code works as it should, but try adding this (renaming the function of course):

    /* Check that BuddyPress is loaded before Achievements */
    function dpa_load_buddypress() {
    if ( function_exists( 'bp_core_setup_globals' ) )
    return true;

    /* Get the list of active sitewide plugins */
    $active_sitewide_plugins = maybe_unserialize( get_site_option( 'active_sitewide_plugins' ) );

    if ( !isset( $active_sidewide_plugins['buddypress/bp-loader.php'] ) )
    return false;

    if ( isset( $active_sidewide_plugins['buddypress/bp-loader.php'] ) && !function_exists( 'bp_core_setup_globals' ) ) {
    require_once( WP_PLUGIN_DIR . '/buddypress/bp-loader.php' );
    return true;
    }

    return false;
    }
    add_action( 'plugins_loaded', 'dpa_load_buddypress', 11 );

    Avatar of Sclough
    sclough
    Participant

    @sclough

    DJPaul, thanks for that idea. I’ll try that!

    Avatar of Sclough
    sclough
    Participant

    @sclough

    I never could get this to work right. I had to instead create a plugin that hooked into actions to save the data and then hooks into the template to add the edit fields on the group profile page.

    Avatar of dpolant
    dpolant
    Participant

    @dpolant

    I am running into this same problem in 1.1.3 with the groups extension api. I found a semi-ridiculous work around – name your plugin directory something that comes after “Buddypress” in the alphabet. Does any one know a way of specifying plugin dependencies?

    Also, I never had this problem until I upgraded to mu 2.9.1. I can’t reproduce this issue on any of my pre-2.9.1 installations. On the older versions BP plugins always manage to get loaded after Buddypress.

    Avatar of dpolant
    dpolant
    Participant

    @dpolant

    I think plugins_loaded is already too late to try and load Buddypress if your plugin got loaded before it. do_action( ‘plugins_loaded comes’ ) after all plugins have been loaded, so if there is a missing class dependency, loading BP after that won’t help.

    The following code works for me:

    function bpgc_load_buddypress() {
    //buddypress is loaded
    if ( function_exists( 'bp_core_setup_globals' ) )
    return false;

    // Get the list of active sitewide plugins
    $active_sitewide_plugins = maybe_unserialize( get_site_option( 'active_sitewide_plugins' ) );
    $bp_activated = $active_sitewide_plugins['buddypress/bp-loader.php'];

    //bp is not activated
    if ( !$bp_activated ){
    return false;
    }

    //bp is activated but not yet loaded
    if ( $bp_activated ) {
    return true;
    }

    return false;
    }

    //load bp if its not activated
    if ( bpgc_load_buddypress() ){
    require_once( WP_PLUGIN_DIR . '/buddypress/bp-loader.php' );
    }

    Add this to the top of your plugin and it ought to load correctly.

    Avatar of Andy Peatling
    Andy Peatling
    Keymaster

    @apeatling

    In the trunk and in version 1.2+ use the action “bp_init” as this will ensure BP is completely loaded before your plugin does anything.

    Avatar of dpolant
    dpolant
    Participant

    @dpolant

    Thanks andy, bp_init does the trick for my class dependencies. I suppose what I should do is create a loader.php file that loads the rest of my files on the action bp_init.

    Also just for the record the code I posted above doesn’t work in 1.2, but it shouldn’t really need to if you use the bp_init action.

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

You must be logged in to reply to this topic.