Deactivate BuddyPress widgets in blogs

Hi all,

I would like to deactivate some BP widgets (recents users, sitewide activity ...) in blogs.
Somes BP widgets requiers 50 queries each, imagine if 20% of all the blogs use these widgets (like "recent users":wink: !!

How can i do it ?

Thank you

  • Aaron
    • CTO

    Ok, I just paid for your premium subscription. :wink:
    <?php
    add_action( 'widgets_init', 'bp_unregister_widgets' );

    function bp_unregister_widgets() {
    global $current_site, $blog_id;

    //ignore main blog
    if ($current_site->blog_id == $blog_id)
    return;

    unregister_widget( 'BP_Activity_Widget' );
    unregister_widget( 'BP_Blogs_Recent_Posts_Widget' );
    unregister_widget( 'BP_Groups_Widget' );
    unregister_widget( 'BP_Core_Welcome_Widget' );
    unregister_widget( 'BP_Core_Members_Widget' );
    unregister_widget( 'BP_Core_Whos_Online_Widget' );
    unregister_widget( 'BP_Core_Recently_Active_Widget' );
    }
    ?>

    That's all the widgets I could find. You can remove or comment out the ones that you want available to all.

  • bloguez
    • WPMU DEV Initiate

    Did not works but this yes :

    add_action('widgets_init', create_function('', 'return unregister_widget( "BP_Activity_Widget" );') );
    add_action('widgets_init', create_function('', 'return unregister_widget( "BP_Blogs_Recent_Posts_Widget" );') );
    add_action('widgets_init', create_function('', 'return unregister_widget( "BP_Groups_Widget" );') );
    add_action('widgets_init', create_function('', 'return unregister_widget( "BP_Core_Welcome_Widget" );') );
    add_action('widgets_init', create_function('', 'return unregister_widget( "BP_Core_Members_Widget" );') );
    add_action('widgets_init', create_function('', 'return unregister_widget( "BP_Core_Whos_Online_Widget" );') );
    add_action('widgets_init', create_function('', 'return unregister_widget( "BP_Core_Recently_Active_Widget" );') );
    add_action('widgets_init', create_function('', 'return unregister_widget("BP_Core_Recently_Active_Widget");') );

    Thanks

  • bloguez
    • WPMU DEV Initiate

    Ok, solved !

    add_action('widgets_init', 'bp_unregister_widgets', 1);
    function bp_unregister_widgets() {
    global $current_site, $blog_id;

    //ignore main blog
    if ($current_site->blog_id == $blog_id)
    return;

    add_action('widgets_init', create_function('', 'return unregister_widget( "BP_Activity_Widget" );') );
    add_action('widgets_init', create_function('', 'return unregister_widget( "BP_Blogs_Recent_Posts_Widget" );') );
    add_action('widgets_init', create_function('', 'return unregister_widget( "BP_Groups_Widget" );') );
    add_action('widgets_init', create_function('', 'return unregister_widget( "BP_Core_Welcome_Widget" );') );
    add_action('widgets_init', create_function('', 'return unregister_widget( "BP_Core_Members_Widget" );') );
    add_action('widgets_init', create_function('', 'return unregister_widget( "BP_Core_Whos_Online_Widget" );') );
    add_action('widgets_init', create_function('', 'return unregister_widget( "BP_Core_Recently_Active_Widget" );') );
    add_action('widgets_init', create_function('', 'return unregister_widget("BP_Core_Recently_Active_Widget":wink:;') );
    }

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.