Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'group_id'

Viewing 25 results - 26 through 50 (of 567 total)
  • Author
    Search Results
  • #322342
    meitalaaa
    Participant

    $defaults = array(
    ‘group_id’ => null,
    ‘creator_id’ => get_current_user_id(),
    ‘name’ => ”,
    ‘description’ => ”,
    ‘slug’ => ”,
    ‘status’ => $status,
    ‘enable_forum’ => 0,
    ‘date_created’ => bp_core_current_time()
    );

    Like this? I’ve changed it, but it’s still not creating the group.

    #322333
    shanebp
    Moderator

    For a new group, leave group_id empty.

    #322332
    meitalaaa
    Participant

    I wrote the following function, but i still can’t create a group. I’ve made sure that the function is getting called, so that is not the issue

    function start_a_new_group($profile_id, $status) {
    if ( !function_exists( ‘groups_create_group’ ) ) {
    require_once ‘/bp-groups/bp-groups-functions.php’;
    }

    $defaults = array(
    ‘group_id’ => $profile_id,
    ‘creator_id’ => get_current_user_id(),
    ‘name’ => ”,
    ‘description’ => ”,
    ‘slug’ => ”,
    ‘status’ => $status,
    ‘enable_forum’ => 0,
    ‘date_created’ => bp_core_current_time()
    );
    return groups_create_group($defaults);
    }

    Wordpress version 5.8.2
    Buddypress verion 9.1.1
    Theme is Twenty Twenty

    Any ideas?

    mdw15
    Participant

    I have this:
    while ( bp_members() ) :
    bp_the_member();

    The bp_the_members is returning null and cause the database error for each member:
    [php7:notice] [pid 2304654] [client 127.0.0.1:51798] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘) AND is_confirmed = 1 AND (is_admin = 0 AND is_mod = 0 AND is_banned = 0) ORDER’ at line 1 for query SELECT user_id FROM wp_bp_groups_members WHERE group_id IN () AND is_confirmed = 1 AND (is_admin = 0 AND is_mod = 0 AND is_banned = 0) ORDER BY date_modified DESC made by require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), include(‘/themes/PSUOutreachMarketing-Challenge/members-search.php’), get_footer, locate_template, load_template, require_once(‘/themes/PSUOutreachMarketing/footer.php’), dynamic_sidebar, WP_Widget->display_callback, WP_Widget_Text->widget, apply_filters(‘widget_text_content’), WP_Hook->apply_filters, do_shortcode, preg_replace_callback, do_shortcode_tag, GFForms::parse_shortcode, GFForms::get_form, GFFormDisplay::get_form, GFFormsModel::get_field_value, GF_Field_Checkbox->get_value_submission, GFFormsModel::get_parameter_value, gf_apply_filters, apply_filters(‘gform_field_value’), WP_Hook->apply_filters, populate_fields, get_all_team_members, bp_group_has_members, BP_Groups_Group_Members_Template->__construct, groups_get_group_members, BP_User_Query->__construct, BP_User_Query->prepare_user_ids_query, BP_Group_Member_Query->get_include_ids, BP_Group_Member_Query->get_group_member_ids, referer:

    This line:
    if ( bp_has_members( ( 0 < count( $my_ids ) )?’include=’.implode(‘,’, $my_ids ):bp_ajax_querystring( ‘members’ ) ) ) :
    is returning a comma separated string list of IDs I want to display.

    Any ideas what is going wrong?

    tccdeveloper05
    Participant

    Wordpress Version: 5.8
    Buddypress Version: 9.1.1
    Link: no link because this is only from localhost.

    So i have these lines of code which displays all exisiting groups from the website and if i select one, it will link/integrate it to a course i selected (LMS).

    <?php
    $groups = groups_get_groups(array(‘show_hidden’ => true));
    $attached_group = (array) \TUTOR_BP\BuddyPressGroups::get_group_ids_by_course(get_the_ID());

    ?>
    <div class=”tutor-option-field-row”>
    <div class=”tutor-option-field-label”>
    <label for=””>
    <?php _e(‘BuddyPress Groups’, ‘tutor-pro’); ?>
    </label>
    </div>
    <div class=”tutor-option-field tutor-field-number”>
    <select name=”_tutor_bp_course_attached_groups[]” class=”tutor_select2″ multiple=”multiple”>
    <?php
    foreach ($groups[‘groups’] as $group){
    $selected = in_array($group->id, $attached_group) ? ‘selected=”selected”‘ : ”;
    echo “<option value='{$group->id}’ {$selected} > {$group->name} </option>”;
    }
    ?>
    </select>
    <p class=”desc”><?php _e(‘Assign this course to BuddyPress Groups’, ‘tutor-pro’); ?></p>
    </div>
    </div>

    However from the <select> options i only want to display the groups i have created. how to do this? any help will be appreciated!

    #320254
    shanebp
    Moderator

    To get members of a specific group, use groups_get_group_members.
    Found in buddypress\bp-groups\bp-groups-functions.php
    Review the function to get all the parameters.
    Example:

    $args = array( 'group_id' => 99 ); 
    $group_members = groups_get_group_members( $args );
    var_dump( $group_members );
    Divvy
    Participant

    Hello guys,

    Can someone please help me?

    I have this code:

    function jwa_get_top_dino_users( $post ){
    global $wpdb;
    $post_id = $post->ID; 
    $results = $wpdb->get_results( "SELECT * FROM " . jwa_get_table_name() . " where dino_id = '$post_id' ORDER BY boost_sum DESC LIMIT 10" ); 
    
     $data = "<div class='jwa-grid-row jwa-single-post'>
    <div class='col-box-12'>
    <div class='jwa-grid-row'>
    <div class='col-box-6'>
    <img src='".get_the_post_thumbnail_url( $post, 'full' )."' class='img-box' style='float: right; margin-right: 30px;' alt='".esc_html( get_the_title( $post ) )."' />
    </div>
    
    <div class='col-box-6 jwa-single-post-data'>
    <div class='jwa-sub-title'><strong>The most powerful ".get_the_title( $post )."</strong>:</div>";
    
    $n = 1; 
    foreach ( $results as $key => $value ) {
    // code...
    $user_id = $value->user_id; // custom type post id
    $dino_id = $value->dino_id; // custom type post id
    $level_boost = $value->level_boost; // user levels
    $health_boost = $value->health_boost; 
    $damage_boost = $value->damage_boost; 
    $speed_boost = $value->speed_boost;
    // $username =  bp_core_get_username( $user_id );
    $username = get_user_by( 'id', $user_id )->display_name ;
    
    $data .= "<div style='margin-left: 10px; padding-bottom: 5px'>$n. ".jwa_strong( $username )."</div>";
    $n++;
    }

    Is it possible to display the $username of the users that are only members of two specific groups?
    bp-groups&gid=2 and bp-groups&gid=5

    Thanks in advance 🙂

    EDIT:

    I have found the following code, but I don’t know how to apply:

    $this_id = bp_get_group_id();
    echo "group id is: " . $this_id;  // make sure there is a value here. 
    $has_members_str = "group_id=" . $this_id;
    if ( bp_group_has_members( $has_members_str ) ) 
    #317775
    shanebp
    Moderator

    Use these functions in your custom code after the user is added and their ID exists:
    Add user to a group: groups_join_group( $group_id, $user_id );
    Make user active on the site: bp_update_user_last_activity( $user_id );

    #317577
    shanebp
    Moderator

    Try this hook: do_action( 'groups_promote_member', $group_id, $user_id, $status );

    Found in: function groups_promote_member

    File: buddypress\bp-groups\bp-groups-functions.php

    #317134
    Mathieu Viet
    Moderator

    Hi,

    It looks like bp_get_current_group_id() doesn’t manage to guess the Group ID out of the Group’s URL when using Ajax. That’s probably because your plugin is adding extra characters into the URL like the short language name.

    You could try filtering bp_uri when doing Ajax to replace these extra characters with nothing.

    eg:

    
    function myshanai_wpml_ajax_fix( $path ) {
       if ( wp_doing_ajax() ) {
          $extracharacters = ''; // replace with the language short name.
          $path = str_replace( $extracharacters, '', $path );
       }
    
       return $path;
    }
    add_filter( 'bp_uri', 'myshanai_wpml_ajax_fix' );
    
    myshanai
    Participant

    I am having problem in my Buddypress Group where group admins cannot send invites.
    Group admin can enter the Invite Members page, select members to invite, then clicked on Send Invites link with number of members to invite. Then a form appears to enter optional messages. Upon clicking the Send button there, a red alert shows that “Invitation failed for (number) users”. On buddypress version 6, the message was “You are not allowed to send invitations for this group”.

    This happens on multilingual installation of WordPress (using WPML) and not selecting the default (English) language. If I choose English, the problem does not happen. I do translate some of the words there for non english version, but could it be the source of the problem?

    Upon debugging into function bp_nouveau_ajax_send_group_invites(), it seems that function bp_get_current_group_id() and $_POST[group_id] both returns group_id = 0

    Any idea on how i could fix this?

    current version:
    wordpress: 5.6
    buddypress: 7.1.0

    #316135
    haitianguy
    Participant

    Hi, i feel like im doing this properly but i never get the right result. i have a custom meta called “featured” in activity meta. For testing purposes the meta values are 1,2,3,4 my goal is to have an activity loop order activities by the meta value. i’ve checked the documentation and i came up with this.

    
    <?php
    
    get_header(); ?>
    
    <?php get_template_part('page-parts/general-title-section'); ?>
    
    <?php get_template_part('page-parts/general-before-wrap');
    
    $atts =  array(
    			'title'            => 'Latest Activity',// title of the section.
    			'pagination'       => 1,// show or not.
    			'load_more'        => 0,
    			'display_comments' => 'threaded',
    			'include'          => false,     // pass an activity_id or string of IDs comma-separated
    			'exclude'          => false,     // pass an activity_id or string of IDs comma-separated
    			'in'               => false,     // comma-separated list or array of activity IDs among which to search
    			'sort'             => 'DESC',    // sort DESC or ASC
    			'page'             => 1,         // which page to load
    			'per_page'         => 5,         // how many per page.
    			'max'              => false,     // max number to return.
    			'count_total'      => true,
    
    			// Scope - pre-built activity filters for a user (friends/groups/favorites/mentions).
    			'scope'            => false,
    
    			// Filtering
    			'user_id'          => false,    // user_id to filter on
    			'object'           => false,    // object to filter on e.g. groups, profile, status, friends
    			'action'           => false,    // action to filter on e.g. activity_update, new_forum_post, profile_updated
    			'primary_id'       => false,    // object ID to filter on e.g. a group_id or forum_id or blog_id etc.
    			'secondary_id'     => false,    // secondary object ID to filter on e.g. a post_id.
    
    			// Searching
    			'search_terms'     => false,         // specify terms to search on.
    			'use_compat'       => bp_use_theme_compat_with_current_theme(),
    			'allow_posting'    => false,    // experimental, some of the themes may not support it.
    			'container_class'  => 'activity',// default container,
    			'hide_on_activity' => 1,// hide on user and group activity pages.
    			'for'              => '', // 'logged','displayed','author'.
    			'role'             => '', // use one or more role here(e.g administrator,editor etc).
                'for_group'        => '',// group slug.
    		);
    
    		$atts['meta_query']= array(
                                        array(
                                            'key' => 'featured',
                                            'value' => '0',
                                            'type' => 'numeric',
                                            'compare' => '!=',
                                            ),
                                            'meta_type' => 'numeric',
                                    'orderby' => 'meta_value_num',
                                    'meta_key' => 'featured',
                                    'order' => 'DESC'
                                    );
    
     ?>
    			<div id="buddypress">
    	
    
    		<?php do_action( 'bp_before_activity_loop' ); 
    		
    		
    		
    	
    
    if ( bp_has_activities( $atts ) ) : ?>
    
                <div class="<?php echo esc_attr( $atts['container_class'] ); ?> 
                <?php if ( ! $atts['display_comments'] ) : ?> hide-activity-comments<?php endif; ?>">
    
                    <ul id="activity-stream" class="activity-list item-list">
    
    					<?php while ( bp_activities() ) : bp_the_activity(); ?>
    						
    						<?php bp_get_template_part( 'buddypress/activity/entry' ); ?>
    					<?php endwhile; ?>
    
    					<?php if ( $atts['load_more'] && bp_activity_has_more_items() ) : ?>
                            <li class="load-more">
                                <a href="<?php bp_activity_load_more_link() ?>"><?php _e( 'Load More', 'buddypress' ); ?></a>
                            </li>
    					<?php endif; ?>
                    </ul>
    
    				<?php if ( $atts['pagination'] && ! $atts['load_more'] ) : ?>
                        <div class="pagination">
                            <div class="pag-count"><?php bp_activity_pagination_count(); ?></div>
                            <div class="pagination-links"><?php bp_activity_pagination_links(); ?></div>
                        </div>
    				<?php endif; ?>
    
                </div> 
    
            <?php else : ?>
                <div id="message" class="info">
                    <p><?php _e( 'Sorry, there was no activity found. Please try a different filter.', 'buddypress' ); ?></p>
                </div>
            <?php endif; ?>
            
    ?>
    			</div>
    		
    
    		<?php do_action( 'bp_after_activity_loop' ); ?>
    
    <?php get_template_part('page-parts/general-after-wrap'); ?>
    
    <?php get_footer(); ?>
    

    everything here works except for the order. for some reason it always orders by activity ID. am i missing something here? Thanks in advance im going crazy with this.

    #315657
    shanebp
    Moderator

    These are the forums for BuddyPress.
    BuddyBoss is a fork of BuddyPress and does some things differently.
    You may have better luck asking the folks at BuddyBoss.

    But here is a hint, instead of unset, use the filter:
    apply_filters( 'bp_rest_group_settings_forum', $fields, $group_id );
    Found here:
    buddyboss-platform\bp-groups\classes\class-bp-rest-group-settings-endpoint.php

    #313457
    markbildner
    Participant

    Thanks for your offer of help! I am not seeing php errors. As for the javascript, it pops up the box and I submit. But then the page reloads but no action occurs. I put some logging into the code (see below) It looks to me like $_REQUEST is not set and so the loop never executes at all. This returns false false false

    function console_log($data){
      echo '<script>';
      echo 'console.log('. json_encode( $data ) .')';
      echo '</script>';
    }
    
    function add_users_to_bpgroup() {   
        if( bp_is_active('groups') ):
                  console_log(isset( $_REQUEST['action'] ));
                  console_log(isset( $_REQUEST['bp_gid'] ));
                  console_log(isset( $_REQUEST['allusers'] ));
            if( isset( $_REQUEST['action'] ) && isset( $_REQUEST['bp_gid'] ) && isset( $_REQUEST['allusers'] ) ) {
                $group_id = $_REQUEST['bp_gid'];
                $users = $_REQUEST['allusers'];
    
                foreach ( $users as $user_id ) {
                    groups_join_group( $group_id, $user_id );
                }
            }
            //form submission
            add_action( 'admin_footer', function() { ?>
                <script type="text/javascript" charset="utf-8">
                    jQuery("select[name='action']").append(jQuery('<option value="groupadd">Add to BP Group</option>'));
                    jQuery("#doaction").click(function(e){
                        if(jQuery("select[name='action'] :selected").val()=="groupadd") { e.preventDefault();
                            gid=prompt("Enter a Group ID","1");
                            jQuery(".wrap form").append('<input type="hidden" name="bp_gid" value="'+gid+'" />').submit();
                        }
                    });
                </script>
            <?php
            });
             
        endif;
    }
    #313451
    markbildner
    Participant

    How to Add Members to a Group via WP Users Screen

    This does not seem to work in buddypress (I’m on 5.5). Can anyone spot the problem? It’s a REALLY important feature because adding users to groups from the Groups screen is super-slow if you have to do a lot of names.

    My guess is that the group_id is not making it back from the popup, but I’m not smart enough to know if that’s true or how to fix it.

    #313284
    etatus
    Participant

    I found a workaround to avoid the creation of duplicate activities for the same cpt post on updating.

    function me_activity_parse_args_filter( $args = array() ) {     
        if ( !empty( $args['type'] ) && $args['type'] == 'new_your-cpt' ) {
                    $activities = bp_activity_get(array(
                            'max' => 1,
                            'filter' => array(
                            'action' => 'new_your-cpt',
                            'secondary_id' =>  $args['secondary_item_id'],
                            ),
                    ) );
                    if (count($activities['activities'])==0) { // The cpt post doesn't have activity yet, so we set the group information
                            $args['component'] = 'groups'; // You could set this as 'component_id' in bp_activity_set_post_type_tracking_args
                            if ( !empty(bp_get_current_group_id()) ) $args['item_id'] = bp_get_current_group_id();
                            if (empty($args['content'])) $args['content'] = '&nbsp;';  // To make sure content filter applies afterwards 
                    } else { // Activity already exists
                            $args['type'] = false; // Delete duplicate activity
                    }
        }     
        return $args;
    }
    add_filter('bp_after_activity_add_parse_args', 'me_activity_parse_args_filter',10,1);
    #313276
    Varun Dubey
    Participant
    #313222
    etatus
    Participant

    Here is another approach. I dont like it at all because you cannot check a custom post type (you dont have the activity object). But it works.

    function me_filter_bp_activity_item_id_before_save( $item_id ) { 
        if ( !empty(bp_get_current_group_id()) ) $item_id = bp_get_current_group_id();
        return $item_id ; 
    }; 
             
    add_filter( 'bp_activity_item_id_before_save', 'me_filter_bp_activity_item_id_before_save', 10, 1 );

    BTW: The value 1 seems to be the default blog ID.

    In this thread @imath explains that:

    Custom Post Type Support for Activity

    #313202
    etatus
    Participant

    I’m also interested in solving this problem (I think the number 1 is actually the user id). The only way I could find is to use bp_before_activity_add_parse_args filter:

    function me_activity_parse_filter( $cpt ) {
        if ( $cpt['type'] == 'your_custom_type' ) {
            $cpt['item_id'] = bp_get_current_group_id();
        }     
        return $cpt;
    }
    add_filter('bp_before_activity_add_parse_args', 'me_activity_parse_filter');

    However, if the cpt post is updated a new activity is created instead updating the original one…

    Note that in bp_activity_set_post_type_tracking_args I have
    'component_id' => 'groups',

    Maybe @imath can help us to solve this issue.

    #312939
    Carlen
    Participant

    Thank you! this did help me realize where my errors were, but wasn’t working because I am using some code of automatic login. For anyone else this is what I came up with that works.

    I set up https://gravitywiz.com/documentation/gravity-forms-populate-anything/ and grab the groups from the wp database. I have them search and select the name, and then pass the value (ID) this to a hidden field.

    I then set up the following code. Included is some code to automatically log them in after they register too.

    function ip_gravity_registration_autologin( $user_id, $user_config, $entry, $password ) {
       $selected_team = rgar( $entry, '13' ); // Replace with the field for group ID	$group_id = $selected_team; //change it to the group ID of your choice
        groups_join_group( $group_id, $user_id );
    // Automatic Login: Only automatically login if we aren't *already* logged in
    if ( ! is_user_logged_in() ) { 
    // Get the user data (for the login)
       $user = get_userdata( $user_id );
    // Sign the user in
    wp_signon( array(
    'user_login' => $user->user_login,
    'user_password' => $password,
    'remember' => false, // Don't set the remember cookie
    ) );
    }
    }
    add_action( 'gform_user_registered', 'ip_gravity_registration_autologin', 10, 4 );
    #312928
    clickallco
    Participant

    This should work

    add_action( 'bp_core_activated_user', 'join_group_on_signup');
    function join_group_on_signup( $user_id ){
        $group_id = 13; //change it to the group ID of your choice
        groups_join_group( $group_id, $user_id );
    }
    #311813
    shanebp
    Moderator

    If you have phpmyadmin, you could try manipulating the database tables.
    Make a full backup of your database first.
    Then open the _bp_groups table, find the row with the id of the group and change value of the creator_id field to your id.
    Then open the _bp_groups_members table, find the row with the group_id and the is_admin field where the value will be “1” – and change the value of the user_id field to your id.

    If that does not work, then there is some code on your site that needs to be removed.
    Check your theme/functions.php and plugins/bp-custom.php if it exists.

    #311608
    mroushforwardedge
    Participant

    When attempting Group Creation, I get the following error:

    Fatal error: Uncaught ArgumentCountError: Too few arguments to function badgeos_add_schools_to_group(), 1 passed in /{…}/edgeubadges.com/wp-includes/class-wp-hook.php on line 289 and exactly 3 expected in /{…}/edgeubadges.com/wp-content/plugins/badgeos-group-management-add-on/includes/badgeos-group-management-functions.php:102 Stack trace: #0 /{…}/edgeubadges.com/wp-includes/class-wp-hook.php(289): badgeos_add_schools_to_group(19) #1 /{…}/edgeubadges.com/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(”, Array) #2 /{…}/edgeubadges.com/wp-includes/plugin.php(478): WP_Hook->do_action(Array) #3 /{…}/edgeubadges.com/wp-content/plugins/buddypress/bp-groups/bp-groups-functions.php(194): do_action(‘groups_create_g…’, 19, Object(BP_Groups_Member), Object(BP_Groups_Group)) #4 /{…}/edgeubadges.com/wp-content/plugins/buddypress/bp-groups/actions/create.php(85): groups in /{…}/edgeubadges.com/wp-content/plugins/badgeos-group-management-add-on/includes/badgeos-group-management-functions.php on line 102
    There has been a critical error on your website.—–
    —————————

    Looking at the code, the line it tells me has a function that wants three arguments passed to it: $group_id, $member, and $group. We were previously able to create groups, but have not been able to since moving to a different web server.

    Any ideas on what is causing this problem? Is there a server setting, or a WP/BOP setting that I have missed?

    WP version: 5.4.1
    BP version: 5.1.2 (same problem happened with 5.2.0 on test site)
    Site: https://www.edgeubadges.com

    #311557
    shanebp
    Moderator

    You are correct. For a private group try this which uses a different hook:

    function schene_promote_group_member( $user_id, $group_id ) {
        $group_member = new BP_Groups_Member( $user_id, $group_id );
        $group_member->promote( 'admin' );
    }
    add_action( 'groups_membership_accepted', 'schene_promote_group_member', 99, 2 );
    #311516
    shanebp
    Moderator

    Use this hook which is available right after they join.
    do_action( 'groups_join_group', $group_id, $user_id );

    Try this in your theme/functions.php or in bp-custom.php:

    function schene_promote_group_member( $group_id, $user_id ) {
        $group_member = new BP_Groups_Member( $user_id, $group_id );
        $group_member->promote( 'admin' );
    }
    add_action( 'groups_join_group', 'schene_promote_group_member', 10, 2 );
Viewing 25 results - 26 through 50 (of 567 total)
Skip to toolbar