Skip to:
Content
Pages
Categories
Search
Top
Bottom

Limit access to Core BP Wigets….

  • @alonetrek

    Participant

    I have the problem that members of my site are using the widgets that come with Buddypress (sitewide activity, members, members online, etc). They use them and then complain about the output or other things, I would like to just make it so only the site admin has access to them, or at least only the main site/blog.

    Is this possible? I am not enough of a php coder to know how to code this myself. I can copy and paste like a pro though :) ANY help would be greatly appreciated.

Viewing 1 replies (of 1 total)
  • @rdob

    Participant

    I had the same problem and here’s what worked for me.

    Open the file with the widgets in this example bp-core-widgets.php

    At the top of the page where the widgets are registered it looks like this:

    /* Register widgets for the core component */
    function bp_core_register_widgets() {
    add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Welcome_Widget");') );
    add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Members_Widget");') );
    add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Whos_Online_Widget");') );
    add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Recently_Active_Widget");') );
    }
    add_action( 'plugins_loaded', 'bp_core_register_widgets' );

    replace it with:

    * Register widgets for the core component */
    function bp_core_register_widgets() {
    //global $wpdb, $supporters_widget_main_blog_only;
    global $current_blog, $wpdb, $all_bp_widgets_main_blog_only;

    //---Config
    //
    $all_bp_widgets_main_blog_only = 'yes'; //Either 'yes' or 'no'
    //
    //

    if ( $all_bp_widgets_main_blog_only == 'yes' ) {
    if ( $wpdb->blogid == 1 ) {
    add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Welcome_Widget");') );
    add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Members_Widget");') );
    add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Whos_Online_Widget");') );
    add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Recently_Active_Widget");') );
    }
    }else{
    add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Welcome_Widget");') );
    add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Members_Widget");') );
    add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Whos_Online_Widget");') );
    add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Recently_Active_Widget");') );
    }
    }
    add_action( 'plugins_loaded', 'bp_core_register_widgets' );

    And that’s it.

    Again as I said it seems to work for me but I don’t know if there are any side effects. I recommend testing it before using on live website. Also remember doing the same for the other widgets under blogs, activity etc.I think you will also need to create a different variable than $all_bp_widgets_main_blog_only in the other widget files (blogs, activities etc.)

    Maybe some of the gurus here could comment on this approach.

Viewing 1 replies (of 1 total)
  • The topic ‘Limit access to Core BP Wigets….’ is closed to new replies.
Skip to toolbar