Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'group_id'

Viewing 25 results - 351 through 375 (of 564 total)
  • Author
    Search Results
  • 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?

    #119341
    evo252
    Participant

    Sorry the code I wanted to show has been stripped:

    `global $bp;
    if(bp_get_current_profile_group_id()==1)
    bp_core_redirect($bp->displayed_user->domain.”profile/edit/group/2″);`

    kizinko
    Participant

    Hey,

    I tried the following code from your post above, but it still isn’t working. :-( The activity from the group I’m trying to hide is still showing up on the home page.


    function bp_my_activity_filter( $a, $activities ) {
    global $bp;

    if ( $bp->current_component != $bp->activity->slug )
    return $activities;

    foreach( $activities->activities as $key => $activity ) {
    if ( $activity->type ==’activity_update’ && $activity->item_id == ‘131’ ) {
    unset( $activities->activities[$key] );
    $activities->total_activity_count = $activities->total_activity_count – 1;
    $activities->activity_count = $activities->activity_count – 1;
    }
    }

    $activities_new = array_values( $activities->activities );
    $activities->activities = $activities_new;
    return $activities;
    }
    add_action( ‘bp_has_activities’, ‘bp_my_activity_filter’, 10, 2 );

    I added the new file /wp-content/plugins/bp-custom.php. I got the group id by adding bp_group_id() into groups-loop.php which is 131 as dictated in the code above. I did a test and removed the first if statement, and it removed all of the activity on that group’s page successfully. Everything from that group was still visible on the home page though.

    By the way, thank you soooo much for helping me with this. I am totally lost on this thing.

    #118882
    Boone Gorges
    Keymaster

    @anointed There is nothing in the BP UI to do this, but you *should* be able to do it by adding a piece of groupmeta:
    `groups_update_groupmeta( $group_id, ‘forum_id’, $forum_id );`

    Should be as simple as that…

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