Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

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

  • juanlopez4691
    Member

    @juanlopez4691

    I finally made up a solution adding some meta fields (blog_id, blog_path, blog_name) to groups on creation:

    `function bp_group_meta_save ( $group_id ) {
    $blog = get_blog_details( get_current_blog_id(), true );

    $fields = array(
    ‘blog_id’ => $blog->blog_id,
    ‘blog_path’ => $blog->path,
    ‘blog_name’ => $blog->blogname
    );

    foreach ( $fields as $field => $value ) {
    groups_update_groupmeta( $group_id, $field, $value );
    }
    }
    add_action( ‘groups_created_group’, ‘bp_group_meta_save’ )`

    When showing the list of groups for the current blog, I build a list with the groups with the blog_id value that matches the blog:

    `function get_groups_by_meta ( $field, $meta_key, $meta_value ) {
    global $wpdb;

    if ( is_string( $meta_value) ) $meta_value = “‘” . $meta_value . “‘”;

    $sql = $wpdb->prepare( “SELECT $field from {$wpdb->base_prefix}bp_groups_groupmeta WHERE meta_key=’$meta_key’ AND meta_value=$meta_value”, OBJECT );
    $res = $wpdb->get_results( $sql );

    return $res;
    }

    function get_groups_by_blogid ( $blog_id = 1 ) {
    $list = get_groups_by_meta( ‘group_id’, ‘blog_id’, $blog_id );

    if ( count( $list ) ) {
    $res = ”;
    foreach ( $list as $item ) {
    $res .= $item->group_id . ‘,’;
    }
    return substr( $res, 0, -1);
    } else {
    return FALSE;
    }
    }`

    And finally, in the groups-loop.php template:

    `$current_blogid = get_current_blog_id();
    if ( $current_blogid > 1) {
    $groups_set = get_groups_by_blogid( $current_blogid );
    ( $groups_set !== FALSE ) ? $extra_args = ‘&include=’ . $groups_set : $extra_args = ‘&include=-1’;
    }

    if ( bp_has_groups( bp_ajax_querystring( ‘groups’ ) . $extra_args ) ) : ?>`

    In my wp-config.php, I have defined BP_ENABLE_MULTIBLOG as true, and also a common place to upload user avatars:

    `//Buddypress multi-sitio
    define( ‘BP_ENABLE_MULTIBLOG’, true );

    //Avatares de usuario comunes a toda la red multisitio
    define( ‘BP_AVATAR_URL’, “http://mainblog/wp-content/uploads” );
    define( ‘BP_AVATAR_UPLOAD_PATH’, ‘F:/xampp/www/mainblog/wp-content/uploads’ );`

    I don’t know if this is a overly complicated solution. I suspect Buddypess 1.6 can deal with this situation (segregated groups, activity, forums but common user base) in a far more simple way, but I have no idea how.

    Any clues?


    juanlopez4691
    Member

    @juanlopez4691

    Thank you very much for your suggestions. I will explore both solutions and try to decide wich one suits me best.

Viewing 2 replies - 1 through 2 (of 2 total)
Skip to toolbar