Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'group_id'

Viewing 25 results - 351 through 375 (of 567 total)
  • Author
    Search Results
  • kodestar
    Member

    I’ve also tried $modgroup = groups_get_group(‘group_id=1’); instead of using an array, and it fixed it for my test user, but randomly some other users can approve images, even though they aren’t members =/

    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?

    notpoppy
    Participant

    @r-a-y OK that didn’t quite work for me but this did:

    `function enable_nav_item () {

    global $bp;

    if ( $bp->groups->current_group->id == MY_GROUP_ID )
    return true;
    else
    return false;
    }`

    I’m not sure why this worked – I got the idea from this old thread. It would be good to know why if someone can explain it to me.

    The way I see it, in order to complete this I now need to create individual versions of the complete code for each group where I require these custom tabs. I am sure there’s vastly more elegant ways of doing this but with my meagre PHP knowledge this is the best I can muster for now!

    Artform
    Participant

    The key here is this line of PHP:

    `<?php if ( bp_has_groups( 'user_id=' . bp_loggedin_user_id() . '&type=alphabetical&max=100&per_page=100&populate_extras=0' ) ) :
    while ( bp_groups() ) : bp_the_group(); ?>`

    Ideally you would want to not output the group right away. You would want the group information to go into a variable for processing. The proper way to do this is with a new plugin or template file.

    So grab all the group names `bp_group_name()` and ids `bp_group_id()` into a PHP array and then run a new loop once you’ve resorted the array.

    r-a-y
    Keymaster

    @notpoppy – For this line:

    `if ( groups_get_groupmeta( $bp->groups->current_group->id, ‘settings_complete’ ) )`

    You could probably change that to do your check against group ID

    eg.

    `if ( bp_get_group_id() == MY_GROUP_ID )
    return true;
    elseif ( bp_get_group_id() == ANOTHER_GROUP_ID )
    return true;
    else
    return false;
    `

    etc.

    If you want to do your check by group name, try using `bp_get_group_name()` in place of `bp_get_group_id()`.

    This is untested, but hopefully this gives you a few ideas to work with.

    #137603
    Paul Wong-Gibbs
    Keymaster

    @edinchez We’ve fixed this for BP 1.6 which should be out in a couple of weeks.

    If you cannot wait, open up register.php in your theme and adjust this line:
    `if ( bp_has_profile( ‘profile_group_id=1’ ) ) :`
    to look like:
    `if ( bp_has_profile( ‘user_id=-1&profile_group_id=1’ ) ) :`

    Please please be sure to revert this change after you upgrade to 1.6; it’s the sort of seemingly-harmless change that could cause some subtly weird behaviour at some point in the future which would take ages to track down :)

    juanmaguerrero
    Participant

    @rogercoathup thanks to your help I just achieved what I wanted :)

    I’m doing this now and it’s working fine (still will polish it a bit more):

    
    if ( !isset( $bp->groups->current_group ) || !$bp->groups->current_group || $gid != $bp->groups->current_group->id ) {
    $group = groups_get_group( array( 'group_id' => $gid ) );
    } else {
    $group = $bp->groups->current_group;
    };
    
    groups_record_activity( array(
    'action'  => apply_filters( 'groups_activity_new_update_action', sprintf( __( '%1$s publicó una actualización en %2$s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( bp_get_group_name( $group ) ) . '</a>' ) ),
    'content'   => $content,
    'type'    => $type,
    'item_id' => $gid,
    'user_id' => $user_id
    )
    )
    

    Thanks a lot for your help!!! :D

    #136542
    frostdawn
    Member

    And the log entry showing an error occuring whenever I try to work with Group forums:
    WordPress database error Table ‘wordpress.wp_bb_topics’ doesn’t exist for query SELECT t.*, g.id as object_id, g.name as object_name, g.slug as object_slug FROM wp_bb_topics AS t JOIN wp_12_bp_groups AS g LEFT JOIN wp_12_bp_groups_groupmeta AS gm ON g.id = gm.group_id WHERE (gm.meta_key = ‘forum_id’ AND gm.meta_value = t.forum_id) AND t.forum_id = ’16’ AND t.topic_status = ‘0’ ORDER BY t.topic_time DESC LIMIT 20 made by require, wp, WP->main, do_action_ref_array, call_user_func_array, bp_screens, do_action, call_user_func_array, groups_screen_group_forum, bp_core_load_template, load_template, require_once, locate_template, load_template, require_once, locate_template, load_template, require_once, bp_has_forum_topics, BP_Forums_Template_Forum->__construct, bp_forums_get_forum_topics, BB_Query->BB_Query, BB_Query->query

    #134966
    orpatech
    Member

    I wrote some custom code which may help you out…..
    `
    $query = mysql_query(“SELECT * FROM bp_groups_members WHERE user_id = $user_id “);
    $numrows = mysql_num_rows($query);
    if ($numrows !=0 ){
    $row = mysql_fetch_Assoc($query);
    $group_id= $row; }
    $query1 = mysql_query(“SELECT * FROM bp_groups WHERE id = $group_id “);
    $numrows1 = mysql_num_rows($query1);
    if ($numrows1 !=0 ){
    $row1 = mysql_fetch_Assoc($query1);
    $group_name= $row1; } `

    and then just used following code to display the group name
    `

    ()

    `

    eberswine
    Participant

    I found this action too — but need some assistance!
    do_action( ‘groups_join_group’, $group_id, $user_id )

    #133823
    eberswine
    Participant

    hmm, can I just use this?
    `groups_update_groupmeta( $group_id, $meta_key, $meta_value ); `

    What is meta key and meta value though?

    #132880
    username_
    Member

    @mrjarbenne Thanks for the links, But those are paid plugins and I am all about the open source! especially if it is for wordpress

    @djpaul Hey was wondering if you might help me out with some idea concepts. I got the whole settings to work and added my own page to the nav bar, that part was easy. However I hit a topping point.

    I thought it would be easier to check if an update was part of a group AND if the user is part of that group. However I am finding it difficult to check this.

    I noticed that in the activity there is a item_id which if it is a group update it is the group Id … but is there any other way to check to see if the activity_update is a group other than this? What about changing the content type to activity_group_update or something… Right now I have this and it seems totally hackish and not good at all. Seems to work to check though but also is invalid for any other update other than a group one….
    ` global $current_user;
    get_currentuserinfo();
    $hide_public_groups = get_user_meta( $current_user->ID, ‘hide_public_groups’ );
    $hide_update = false;
    if ( $hide_public_groups[0] == “yes” ) {
    global $activities_template;
    $group_id = $activities_template->activity->item_id;

    $is_member_of_group = check_is_member_of_group( $current_user->ID, $group_id );
    //echo $is_member_of_group;
    if ( $is_member_of_group ) {
    //this is working but is filtering out any other post
    //need to check for if this is not a group post to just let it slide.
    //maybe it is better to grab the groups_loop real quick and then just query for this specific group and then make sure it is public and is member….
    //echo “no hide”;
    //var_dump($group);
    } else {
    //echo “hide it”;
    //$hide_update = true;

    }
    } `

    Also just a note the check_is_member_of_group i stole from the class Bp_Groups_Member…
    Any ideas anyone? I know this should be easier and I am way over thinking it.. It was late last night…

    #130947
    shanebp
    Moderator

    In bp-activity-functions.php
    there is
    function bp_activity_post_update
    which has
    ` do_action( ‘bp_activity_posted_update’, $content, $user_id, $activity_id );`

    I would use add_action in bp-custom to run a function that takes the $activity_id and does whatever you need.

    Ditto for
    do_action( ‘bp_groups_posted_update’, $content, $user_id, $group_id, $activity_id );
    in
    bp-groups.php

    #130922
    Jacob Schweitzer
    Participant

    I tried the bp-default theme, I’m not using any other BuddyPress plugins.

    Found a solution – the problem is a cookie set by BuddyPress that isn’t changing correctly or has the wrong expiration time.

    Line 130 of bp-groups-actions.php (in the bp-groups folder):
    setcookie( ‘bp_new_group_id’, $bp->groups->new_group_id, time()+60*60*24, COOKIEPATH );

    I commented this line out. You could also change the time to a shorter time so bots don’t create groups, is that why this is in there? As it is now, this cookie prevents anyone from creating more than 1 group per 24 hours. Why?

    Hugo Ashmore
    Participant

    You’ll need to do something like wrap the custom xprofile loop section in a check for a specific field name ‘birthdate’ and do something like ‘if not’ ‘birthdate’ go ahead and display field item or display if is_admin if you want to be able to see users data as a site admin.

    To remove a field you could do:
    `

    <tr>

    `
    in the profile loop; equally if you wanted to remove a complete field group you can copy the approach seen in the file for ensuring that the base group is not shown `if ( 1 != bp_get_the_profile_group_id() ) ` adding an OR followed by a check on the group id to hide.

    #126613
    charlz
    Member

    OK. I seem to have found a solution, so I’m gonna share it here:

    First, I replaced the groups_screen_group_admin_delete_group with a slightly changed version where I call a custom function after this line:
    `do_action( ‘groups_before_group_deleted’, $bp->groups->current_group->id );`

    Remember to register this correctly! In my case:
    `
    remove_action( ‘bp_screens’, ‘groups_screen_group_admin_delete_group’ );
    add_action( ‘bp_screens’, ‘myplugin_groups_screen_group_admin_delete_group’ );
    `

    where ‘myplugin_groups_screen_group_admin_delete_group’ is the name of the function.

    The function I call makes use of groups_delete_group_forum_topic( $topic_id ) and bb_delete_forum( $forum_id ). This way, you delete the group and keep the db tidy!
    `
    $forum_id_array = $wpdb->get_results($wpdb->prepare(“
    SELECT forum_id FROM wp_bb_forums
    WHERE forum_id = (
    SELECT meta_value
    FROM wp_bp_groups_groupmeta
    WHERE meta_key = ‘forum_id’
    AND group_id = %s
    ) ;”
    , $group_id));
    $forum_id = $forum_id_array[0]->forum_id;
    $topic_id_array = $wpdb->get_results($wpdb->prepare(“
    SELECT topic_id FROM wp_bb_posts
    WHERE forum_id = %s;”
    , $forum_id));

    foreach ($topic_id_array as $value) {
    groups_delete_group_forum_topic( $value->topic_id );
    }
    bb_delete_forum( $forum_id );
    `

    #124700
    r-a-y
    Keymaster

    I encountered this weird behavior as well when I was doing some testing on a BP site.

    A workaround is to open up /wp-content/themes/YOUR-THEME/registration/register.php.

    Find this code snippet:
    if ( bp_has_profile( 'profile_group_id=1' ) ) :

    And change it to:
    if ( bp_has_profile( 'user_id=-1&profile_group_id=1' ) ) :

    #123500
    rich
    Member

    if you have the group_id
    `
    check_is_admin( $user_id, $group_id )
    check_is_mod( $user_id, $group_id )
    `

    or
    `
    BP_Groups_Member::get_is_mod_of( $user_id )
    BP_Groups_Member::get_is_admin_of( $user_id )
    `

    which returns an array with number of groups & the groups

    wiking
    Member

    As there was a php error if the user who uses the forum directory is not logged in the following modification was done:

    Code:
    //Get current user
    $current_user = wp_get_current_user();

    //Fetch forums IDs to which user has access
    $i = 0;
    $result = mysql_query("SELECT meta_value FROM oba_bp_groups_members, oba_bp_groups_groupmeta WHERE user_id = ".$current_user->ID." and oba_bp_groups_members.group_id = oba_bp_groups_groupmeta.group_id and oba_bp_groups_groupmeta.meta_key=’forum_id’")
    or die ("MySQL-Error: " . mysql_error());
    while ( $row = mysql_fetch_array($result)) {
    $res[$i] = $row["meta_value"];
    $i++;
    }

    //Implode forum ids into a comma sperated list e.g: 3,5,7
    if ( !empty( $res ) )
    $comma_separated = implode(",", $res);

    // Set this for groups
    //Old //$parts[‘groups’] = "(gm.meta_key = ‘forum_id’ AND gm.meta_value = t.forum_id)";
    $parts[‘groups’] = "(gm.meta_key = ‘forum_id’ AND gm.meta_value = t.forum_id AND gm.meta_value IN (".$comma_separated."))";

    You also need to add the functionality that logged in users can potentially see all forums (the above code then filters out forums the user is not member of):

    after

    Code:
    // Are we a super admin?
    elseif ( is_super_admin() )
    unset( $parts[‘private’] );

    add

    Code:
    // Allow the forum directory to display private forums for users
    elseif ( is_user_logged_in() )
    unset( $parts[‘private’] );
    Sirup
    Member

    This problem is solved.
    In in “bp-groups-filters.php” in function “function groups_add_forum_where_sql( $sql = ” ) ” change the following (oba is the database prefix):

    Code:
    //Get current user
    $current_user = wp_get_current_user();

    //Fetch forums IDs to which user has access
    $i = 0;
    $result = mysql_query("SELECT meta_value FROM oba_bp_groups_members, oba_bp_groups_groupmeta WHERE user_id = ".$current_user->ID." and oba_bp_groups_members.group_id = oba_bp_groups_groupmeta.group_id and oba_bp_groups_groupmeta.meta_key=’forum_id’")
    or die ("MySQL-Error: " . mysql_error());
    while ( $row = mysql_fetch_array($result)) {
    $res[$i] = $row["meta_value"];
    $i++;
    }

    //Implode forum ids into a comma sperated list e.g: 3,5,7
    $comma_separated = implode(",", $res);

    // Set this for groups
    //Old //$parts[‘groups’] = "(gm.meta_key = ‘forum_id’ AND gm.meta_value = t.forum_id)";
    $parts[‘groups’] = "(gm.meta_key = ‘forum_id’ AND gm.meta_value = t.forum_id AND gm.meta_value IN (".$comma_separated."))";

    wiking
    Member

    I still struggle to get this view running corectly.

    I managed to find out how to pull all group ID’s for a given userid:

    SELECT group_id FROM `xyz_bp_groups_members` where `user_id` = 1

    And how to get all forum_id’s for a given group:

    SELECT meta_value FROM `xyz_bp_groups_groupmeta` where group_id = 1 and meta_key = ‘forum_id’

    My idea was to do a join as i didn’t know how to follow your directions correctly @boonebgorges.
    Therefore i tried to modify the original $sql (line 83 in bp-group-filters.php):

    $sql .= ‘JOIN ‘ . $bp->groups->table_name . ‘ AS g LEFT JOIN ‘ . $bp->groups->table_name_groupmeta . ‘ AS gm ON g.id = gm.group_id ‘;

    with this extended version:

    $sql .= ‘JOIN ‘ . $bp->groups->table_name . ‘ AS g LEFT JOIN ‘ . $bp->groups->table_name_groupmeta . ‘ AS gm, oba_bp_groups_members AS gu ON g.id = gm.group_id AND gu.group_id = gm.group_id’;

    unfortunately i have not enough know-how how the buddypress-core is working correctly. Any hints on how to do this properly?

    Many Thanks!

    sdls
    Member

    Thanks both for the feedback!… looking into xprofile_insert_field() in bp-xprofile/bp-xprofile-functions.php. This appears to be the function for adding a new profile field to the BP system.

    `function xprofile_insert_field( $args = ” ) {
    global $bp;

    extract( $args );

    /**
    * Possible parameters (pass as assoc array):
    * ‘field_id’
    * ‘field_group_id’
    * ‘parent_id’
    * ‘type’
    * ‘name’
    * ‘description’
    * ‘is_required’
    * ‘can_delete’
    * ‘field_order’
    * ‘order_by’
    * ‘is_default_option’
    * ‘option_order’
    */

    // Check we have the minimum details
    if ( !$field_group_id )
    return false;

    // Check this is a valid field type
    if ( !in_array( $type, (array) $bp->profile->field_types ) )
    return false;

    // Instantiate a new field object
    if ( $field_id )
    $field = new BP_XProfile_Field( $field_id );
    else
    $field = new BP_XProfile_Field;

    $field->group_id = $field_group_id;

    if ( !empty( $parent_id ) )
    $field->parent_id = $parent_id;

    if ( !empty( $type ) )
    $field->type = $type;

    if ( !empty( $name ) )
    $field->name = $name;

    if ( !empty( $description ) )
    $field->description = $description;

    if ( !empty( $is_required ) )
    $field->is_required = $is_required;

    if ( !empty( $can_delete ) )
    $field->can_delete = $can_delete;

    if ( !empty( $field_order ) )
    $field->field_order = $field_order;

    if ( !empty( $order_by ) )
    $field->order_by = $order_by;

    if ( !empty( $is_default_option ) )
    $field->is_default_option = $is_default_option;

    if ( !empty( $option_order ) )
    $field->option_order = $option_order;

    return $field->save();
    }
    `
    All I really need to do is add a little record into the existing “wp_bp_xprofile_data” table

    This below code works however it’s definately not Open source friendly or BP friendly

    `

    // grab this users nicename

    $user = get_userdata( $iallusersUserID );
    $nicename = $user->user_nicename;
    $last_udpated = date(‘Y-m-d H:i:s’);

    // create a new record in bp_xprofile_data and add the nicename

    $wpdb->insert(
    ‘wp_bp_xprofile_data’,
    array(
    ‘field_id’ => 1,
    ‘user_id’ => $iallusersUserID,
    ‘value’ => $nicename,
    ‘last_updated’ => $last_udpated
    ),
    array(
    ‘%d’,
    ‘%d’,
    ‘%s’,
    ‘%s’
    )
    );
    `

    Any thoughts? Thanks again!

    #119647
    Paul Wong-Gibbs
    Keymaster

    BP_Groups_Group::group_exists returns the group ID, from the group name. A better named function isn’t going to improve the functionality.

    #119627
    sirspacey
    Member

    This worked. The proper syntax for group id: $team_id = bp_get_group_id();

    #119624
    sirspacey
    Member

    Any word on a better function for this?

Viewing 25 results - 351 through 375 (of 567 total)
Skip to toolbar