BuddyPress Group Calendar on Just a Sub Site

I'm trying to run BuddyPress Group Calendar on just a single sub site in a multisite network. I see that the plugin was only 'network active', so I tried changing that to 'Network: false'. I also updated the database prefix from 'base_prefix' to just 'prefix'. I deactivated and activated the plugin, however when I go to post a group calendar event it says "There was a problem saving to the DB". Please advise on how I can make this work for a single sub site.

  • Kasia Swiderska

    Hello Jason,

    I'm not sure that is possible to activate that plugin this way - I will check that with developer and get back to you with answer.

    However that plugin runs only with BuddyPress - so if your BuddyPress is only activated on one subsite then if you Network activate Group Calendar it will only be available for subsite where BuddyPress is.
    How it looks in your network?

    kind regards,
    Kasia

  • Panos

    Hi Jason Verdelli ,

    I think you can simply remove the Network: true line and activate the plugin only on the blog(s) you need it.

    Another way would be to activate it network wide, edit file wp-content/plugins/bp-group-calendar/groupcalendar/bp-group-calendar.php and at line ~198 add the following:

    $allowed_to_register_ext = apply_filters( 'bp_calendar_ext/register_ext', true );
    if( $allowed_to_register_ext )

    just before :

    bp_register_group_extension( 'BP_Group_Calendar_Extension' );

    Then save and add the following snippet on a mu-plugin:

    function wpmudev_calendar_ext_check(){
    
    	if( is_multisite() ){
    		$allowed_blogs = array( 18, 23, 24, 86 );
    		if( ! in_array( get_current_blog_id(), $allowed_blogs ) ) {
    			remove_action( 'groups_group_after_save', 'bp_group_calendar_settings_save' );
    			remove_action( 'bp_after_group_settings_creation_step', 'bp_group_calendar_settings' );
    			remove_action( 'bp_after_group_settings_admin', 'bp_group_calendar_settings' );
    			remove_action( 'wp_enqueue_scripts', 'bp_group_calendar_js' );
    			return false;
    		}
    
    	}
    	return true;
    }
    
    add_filter( 'bp_calendar_ext/register_ext', 'wpmudev_calendar_ext_check' );

    In the line
    $allowed_blogs = array( 18, 23, 24, 86 );
    you can add the ids of the blogs you want to show the calendar.

    Hope this helps!
    Panos

  • Jason Verdelli

    I figured it out. It deals with the following line on bp-group-calendar.php (around line 80):

    if ( get_site_option( "bp_group_calendar_installed" ) == "yes" ) {

    If you activate the plugin in a single site (removing the 'Network: true' option from loader.php), but don't edit the database prefix to 'prefix' instead of 'base_prefix', it won't create the necessary table for that sub site because of the if statement as shown above. The solution was to just add the code that creates table after the line above and then set it back to normal once the plugin was deactivated and activated again. It's a bit of a work around, but it's what needed to happen to create the necessary table.

    I'm wondering if instead of adding a record like this into the site meta (bp_group_calendar_installed), it should be updated to run a condition against if the table is created or not. That seems a bit more logical than what's currently there. Thoughts?