Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'group_id'

Viewing 25 results - 151 through 175 (of 564 total)
  • Author
    Search Results
  • r-a-y
    Keymaster

    @sharmavishal – Can you add the following in wp-content/plugins/buddypress/bp-groups/classes/class-bp-group-extension.php:

    if ( defined( 'WP_NETWORK_ADMIN' ) ) {
    	echo get_called_class();
    }
    

    Right before this:

    // Usually this will work.
    $group_id = bp_get_current_group_id();
    

    This should print the names of the group extension classes that are being loaded right before the fatal error.

    Can you copy and paste this info here?

    Thanks!

    sharmavishal
    Participant

    @r-a-y existing multisite site setup. bp activated network wide. added a new site via add new site in admin….the site added page comes up..but when u click on dashboard of new site or visit new site both dont come up….the error mentioned before….tested with rc1 bp also..following debug error with rc1:

    Fatal error: Call to undefined function bp_get_current_group_id() in /wp-content/plugins/buddypress/bp-groups/classes/class-bp-group-extension.php on line 484

    Garrett Hyder
    Participant

    In the end utilizing BP_Media_Extractor with wp_oembed_get and do_shortcode I was able to get this functional;

    
    $group_content = groups_get_groupmeta(bp_get_group_id(), 'bp_group_content_editor');
    
    if(!empty($group_content)) {
    	$bp_extractor = new BP_Media_Extractor;
    	$media = $bp_extractor->extract( $group_content, BP_Media_Extractor::ALL );
    	if ( ! empty( $media['embeds'] ) ) {
    		foreach ( $media['embeds'] as $embed ) {
    			$cachekey = '_oembed_response_' . md5( $embed['url'] );
    			$oembed = groups_get_groupmeta( bp_get_group_id(), $cachekey );
    			if ( '' === $oembed ) {
    				$oembed = wp_oembed_get($embed['url']);
    				groups_update_groupmeta( bp_get_group_id(), $cachekey, $oembed );
    			}
    			if ( $oembed ) {
    				$group_content = str_replace($embed['url'], $oembed, $group_content);
    			}
    		}
    	}
    	if ( ! empty( $media['shortcodes'] ) ) {
    		foreach ( $media['shortcodes'] as $shortcode ) {
    			$cachekey = '_shortcode_response_' . md5( $shortcode['original'] );
    			$shortcode_content = groups_get_groupmeta( bp_get_group_id(), $cachekey );
    			if ( '' === $shortcode_content ) {
    				$shortcode_content = do_shortcode($shortcode['original']);
    				groups_update_groupmeta( bp_get_group_id(), $cachekey, $shortcode_content );
    			}
    			if ( $shortcode_content ) {
    				$group_content = str_replace($shortcode['original'], $shortcode_content, $group_content);
    			}
    		}
    	}
        echo wpautop($group_content);
    }
    
    shanebp
    Moderator

    It’s a delicate fix.
    Backup your database first.

    Then try this…

    Don’t delete the current field – Change it to a selectbox.
    Note the field_id ( in the wp-admin url )

    Then adapt and run this function to add countries:
    https://gist.github.com/shanebp/119ffd879acc56c324ab

    Use these parts:

    $countries = array( ... ); 
    
    foreach (  $countries as $country ) {
    	
    	xprofile_insert_field( array(
    		'field_group_id'	=> 1,
    		'parent_id'		=> 28,  // the field_id of the field
    		'type'			=> 'option',
    		'name'			=> $country,
    		'option_order'   	=> $i++
    	));
    	
    }
    #251532
    jrytesting
    Participant

    Hello, I had this same problem and this is how I fixed it. It was mentioned in this thread
    (https://buddypress.org/support/topic/bad-link-to-profile-edit/)
    that there may be a problem in the database table “wp_bp_xprofile_groups”. For some reason the first item id there is not “1” but something else. As you change the id to 1, everything works. Then it also shows the Profile details side Name field (required) in the registration page.

    Also there was a problem to edit profile, it went to “Page not found”. This gets fixed also now, now you can edit the fields.

    This seems to be some kind of bug in the installing process in some circumstances. I tested this by removing the BuddyPress and also deleting the BuddyPress database tables. They must be deleted manually, they wont get out by deleting the plugin.

    New installation put the first id number to “3” to “wp_bp_xprofile_groups” table. Even the group_id in the table “wp_bp_xprofile_fields” was “1” (after I activated some components in BuddyPress menu, before that the tables were empty) for the first field item. So now the field item and the group item never matched.

    Hopefully this helps someone. It seems that there are a lot of discussion of this problem, and this is a very annoying problem if you are really using BuddyPress.

    Basically the registering had a workaround for example by using plugin “Theme my login”. The registering also looks simpler as there is not that “extra” name field. It is however unknown how BuddyPress works without that name field. Well, but perhaps that is an another story.

    #250985
    shanebp
    Moderator

    Did you try explicitly setting the forum id?
    Something like:

    if( bp_group_is_forum_enabled($group) ) {
    	$forum_id = groups_get_groupmeta( bp_get_group_id(), 'forum_id' );
    	echo 'forum id: ' . $forum_id;
    	$bbp_args = array( 'post_parent' => $forum_id ); 
    	if ( bbp_has_topics( $bbp_args ) ) {
            //etc
    #250852
    Paul Wong-Gibbs
    Keymaster

    I took a quick look and can’t see one function. There’s probably a better way, but you could use xprofile_get_field_id_from_name( $name ) and pass that to xprofile_get_field( ... ) to get a BP_XProfile_Field object, then access its ->$group_id property.

    #249833
    shanebp
    Moderator

    Use the group slug:
    $group_id = groups_get_id( $group_slug );

    twobyte
    Participant

    Great thanks.

    I added a custom shortcode to the form to embed group_id as a hidden input field then changed the wpcf7_mail_components filter:

    
    add_filter( 'wpcf7_mail_components', 'ccc_group_mail_components', 10, 3 );
    
    function ccc_group_mail_components( $components ) {
    	global $bp;
    	if ( isset( $_POST['group_id']) && $_POST['group_id'] > 0 ) {
    		$group_id = $_POST['group_id'];
    		$groupadmins = groups_get_group_admins( $group_id );
    		$recipients = array();
    		foreach( $groupadmins as $admin ) {
    	   		$admin_info = get_userdata($admin->user_id);
    			$recipients[] = $admin_info->user_email;
    		}
    		if(count($recipients)>0){
    			$components['recipient'] = implode(",", $recipients);
    		}else {
    			// append a little alert to subject line so we know admin emails werenโ€˜t found.
    			$components['subject'] = $components['subject']. ' (Error: No group admins found)' ;
    		}
    		// lets tag subject line with group section as well for traceability
    		$group = groups_get_group( array( 'group_id' => $group_id) );
    		$components['subject'] = '['.$group->name.'] '.$components['subject'];
    		
    	}
    		
    	return $components;
    }
    

    It works now but I was having a proper time trying to get group name using bp_get_group_name($group_id) instead of groups_get_group( array( ‘group_id’ => $group_id) ). I suppose the former must be used in the loop!

    shanebp
    Moderator

    After you submit the form, are you still on the group page?

    I doubt that your filter function is aware of the Group.

    Can you pass parameters to the shortcode?
    If so, pass in the $group_id$group_id = bp_get_group_id();
    Then use it in the filter to get the user ids of group admins
    groups_get_group_admins( $group_id );
    And use the result to get email addys.

    #248850
    Slava Abakumov
    Moderator

    All fields that are in the first Base fields groups will appear on registration page.
    So you can just move those fields to another fields group, that you can create on this page /wp-admin/users.php?page=bp-profile-setup using this link http://cosydale.com/wp-admin/users.php?page=bp-profile-setup&mode=add_group.

    Another option

    Find the ID of a field that you want to hide in admin area (when you edit the field it’s in the URL like this /wp-admin/users.php?page=bp-profile-setup&group_id=1&field_id=2&mode=edit_field = field_id=2 is what you need), make sure that this field is NOT required, then open style.css of your theme and add there something like this:
    #profile-details-section.register-section .editfield.field_2 {display:none}
    For reference: http://take.ms/lONUD

    #248640
    Henry Wright
    Moderator

    The code you’ve posted gets the current group and first compares that group’s slug to social-group-547668396. If a match occurs, the default tab is set to calendar. If no match occurs then the group’s slug is compared to husbands-out. If a match occurs, the default tab is set to forum. If the group’s slug doesn’t match any of those, the default tab is set to home.

    I don’t think any of this will happen at the point a join group button is clicked.

    My thinking is you will need to hook to an action such as groups_join_group (which will fire immediately after a user joins a group) and then perform a direct to the forum tab (or to the default tab if that is set to forum).

    I think something like this:

    function my_redirect_after_join_group( $group_id, $user_id ) {
        $group = groups_get_group( array( 'group_id' => $group_id ) );
        bp_core_redirect( bp_get_groups_directory_permalink() . $group->slug . '/forum/' );
    }
    add_action( 'groups_join_group', 'my_redirect_after_join_group', 10, 2 );

    Please note I haven’t tested.

    #248468
    markc
    Participant

    Thanks @ubernaut. I have a forum topic called “General” so I create a Group also called “General” but I can’t figure out how to enable the imported General topic to become THE forum for the newly created General Group. I found these vague old instructions but no luck so far. Would you have any clues how I could link the imported forum topic to the group?

    Set up a new group for each forum (a โ€œHelpโ€ forum might get a โ€œHelpโ€ group, for example), make sure the group has discussion forums enabled, and then find the line in table wp_bp_groups_groupmeta corresponding to the group_id of the new group and meta key forum_id, and change the meta_value to match the forum number of the orphan group. Rinse and repeat.

    Brajesh Singh
    Participant

    Hi George,
    No, There is no API function to fetch field group id from field group name and you will need to write your own sql query for the purpose.

    Also, In your example you have passed the profile_group_id to the bp_get_profile_field_data. Please note, it does not take that as a valid argument. It only accepts user_id and field. group id is not required for fetching field data.

    Now, If we forget about the group name API and come to the original requirement, Do you plan to fetch the data for multiple users(In loop) or just once/twice.

    For fetching data, these two functions work

    You can either use

    
    $data = xprofile_get_field_data( $field, $user_id = 0, $multi_format = 'array' )
    
    

    where $field is field id or name( If you know the id, It will fetch from any group, Name has the issue)

    or as you specified

    
    $data = bp_get_profile_field_data( array(
    	'user_id'	=> $user_id,
    	'field_id'	=> $field
    	
    ) );
    
    

    The xprofile data APIs do not allow passing group in general. You either pass a field id or name.

    The problem will happen when multiple fields have same name. In that case, the first field with the name matches if you use the above functions.

    Another point, In both the cases, There is no group arguement and if you use field name, that will need one extra query(field id should be preferred if the id is known).

    Honestly speaking, It is ok to use it one or 2 time on page but avoid using it inside the loop. If you plan to use it inside the loop, you should try to first fetch the xprofile data and cache and then use any of these functions. One way to cache will be by calling

    
    
    BP_XProfile_ProfileData::get_value_byid( $field_id, $user_ids )
    

    Where $field_id is the id of field(not name) and $user_ids is one or more user ids.

    Hope that helps.

    #246843
    doubleF
    Participant

    Hi @r-a-y,

    Here is the function :

    function woffice_birthdays_add_field() {
    	
    	if ( bp_is_active( 'xprofile' ) ){
    		global $bp;
    		global $wpdb;
    		// We check for multisite : 
    	    if (is_multisite() && is_main_site()) {
    		    $table_name = $wpdb->base_prefix .'bp_xprofile_fields';
    	    } else {
    	    	$table_name = $wpdb->prefix .'bp_xprofile_fields';
    	    }
    	    $sqlStr = "SELECT <code>id</code> FROM $table_name WHERE <code>name</code> = 'Birthday'";
    	    $field = $wpdb->get_results($sqlStr);
    	    if(count($field) > 0)
    	    {
    	        return;
    	    }
    		xprofile_insert_field(
    	        array (
    	        	'field_group_id'  => 1,
    	            'field_id' => 'woffice_birthday',
    				'can_delete' => true,
    				'type' => 'datebox',
    				'description' => __('We will only use it for the Birthday widget, so we can celebrate everyone\s birthday.','woffice'),
    				'name' => 'Birthday',
    				'field_order'     => 1,
    				'is_required'     => false,
    	        )
    	    );
    	 }
    	 
    }		
    add_action('bp_init', 'woffice_birthdays_add_field');

    I’m able to reproduce it so I’ll try to troubleshoot it now ๐Ÿ˜‰ I keep you updated,

    2F

    #246458
    buckyb
    Participant

    I think I’m close ๐Ÿ™‚

    I got the field I want to show up on my custom page, but I can’t figure out how to make it edit and submit the changes to the right group. Here’s what I’m using in my custom editing page:

    <?php do_action( ‘bp_before_profile_edit_content’ );

    if ( bp_has_profile( ‘profile_group_id=’ . bp_get_current_profile_group_id() ) ) :
    while ( bp_profile_groups() ) : bp_the_profile_group(); ?>

    <div>
    <form action=”<?php bp_the_profile_group_edit_form_action(); ?>” method=”post” id=”profile-edit-form” class=”standard-form my-group”>

    <label for=”field_1″>Custom Field</label>
    <input id=”field_1″ type=”text” value=”<?php echo xprofile_get_field_data(‘Custom Field’); ?>” >

    <?php do_action( ‘bp_after_profile_field_content’ ); ?>

    <div class=”submit”>
    <input type=”submit” name=”profile-group-edit-submit” id=”profile-group-edit-submit” value=”<?php _e( ‘Save Changes’, ‘buddypress’ ); ?> ” />
    </div>

    <input type=”hidden” name=”field_ids” id=”field_ids” value=”29,19,20″ />

    <?php wp_nonce_field( ‘bp_xprofile_edit’ ); ?>

    </form>

    </div>
    <?php ?>

    <?php endwhile; ?>

    <?php endif; ?>

    <?php do_action( ‘bp_after_profile_edit_content’ ); ?>

    #246291
    paragbhagwat
    Participant

    Thanks a lot Henry.. i tried that i am sure i am doing something wrong.. this is what i have and for some reason nothing happens… What am i doing wrong?

    add_action('groups_group_before_save','RECN_CUSTOM_CHECK_DUPLICATE_NAME');
    function RECN_CUSTOM_CHECK_DUPLICATE_NAME($fogroup)
    {
        
        if ( class_exists( 'BP_Groups_Group' ) ) : //
    
            $group_id = BP_Groups_Group::group_exists( $fogroup->slug );
    
            if(!empty($group_id))
            {
                bp_core_add_message( 'A group with the same name already exists. Please search for the existing group to send a membership request.', 'error' );
                $fogroup->name=null;
                return $fogroup;
            }
    endif;
        return $fogroup;
    }
    #244265
    palmdoc
    Participant

    Hmm somehow I don’t see the selector. I have placed bp-custom.php in the root of the plugins folder

    and this is the code

    <?php
    // hacks and mods will go here
    // remove users from groups
    add_action('load-users.php',function() {
    
    if(isset($_GET['action']) && isset($_GET['bp_gid']) && isset($_GET['users'])) {
        $group_id = $_GET['bp_gid'];
        $users = $_GET['users'];
        foreach ($users as $user_id) {
            groups_leave_group( $group_id, $user_id );
        }
    }
        //Add some Javascript to handle the form submission
        add_action('admin_footer',function(){ ?>
        <script>
            jQuery("select[name='action']").append(jQuery('<option value="groupleave">Remove from BP Group</option>'));
            jQuery("#doaction").click(function(e){
                if(jQuery("select[name='action'] :selected").val()=="groupleave") { e.preventDefault();
                    gid=prompt("Please enter a BuddyPres Group ID","");
                    jQuery(".wrap form").append('<input type="hidden" name="bp_gid" value="'+gid+'" />').submit();
                }
            });
        </script>
        <?php
        });
    });
    ?>

    I wonder what I’m doing wrong?
    This is what I’m seeing:

    #244233
    danbp
    Participant

    hi @palmdoc,

    as expected by @henrywright, there is an easier solution from backend. I quickly tested it and it seems to work.

    The snippet will add a bulk option to members list (in admin), which let you remove users from groups. Like on front-end, the admin user list is searchable by user.

    Add this to bp-custom.php

    // remove users from groups
    add_action('load-users.php',function() {
    
    if(isset($_GET['action']) && isset($_GET['bp_gid']) && isset($_GET['users'])) {
        $group_id = $_GET['bp_gid'];
        $users = $_GET['users'];
        foreach ($users as $user_id) {
            groups_leave_group( $group_id, $user_id );
        }
    }
        //Add some Javascript to handle the form submission
        add_action('admin_footer',function(){ ?>
        <script>
            jQuery("select[name='action']").append(jQuery('<option value="groupleave">Remove from BP Group</option>'));
            jQuery("#doaction").click(function(e){
                if(jQuery("select[name='action'] :selected").val()=="groupleave") { e.preventDefault();
                    gid=prompt("Please enter a BuddyPres Group ID","");
                    jQuery(".wrap form").append('<input type="hidden" name="bp_gid" value="'+gid+'" />').submit();
                }
            });
        </script>
        <?php
        });
    });
    #244228
    Henry Wright
    Moderator

    There may be an easier way via the back-end (I haven’t checked) but via code you could do this in functions.php:

    
    function palmdoc_remove_group_user() {
        $group_id = 6 // Change this value
        $user_id = 320 // Change this value
        groups_leave_group( $group_id, $user_id );
    
    }
    add_action( 'init', 'palmdoc_remove_group_user' );

    The next time you visit your website in a browser, the user will be removed from the group.

    Whilst you’re not using it just comment out the add_action() part. For example:

    // add_action( 'init', 'palmdoc_remove_group_user' );

    #244045
    nikhilnaik
    Participant

    I got this code snippet which gives the names of the groups to which the user belongs to –

    <?php 
    $group_ids = groups_get_user_groups(bp_displayed_user_id());
    foreach($group_ids["groups"] as $group_id) { 
    	echo(groups_get_group(array( 'group_id' => $group_id )) -> name . (end($group_ids["groups"]) == $group_id ? '' : ', ' ) ); 
    	}
    ?>

    Now, just need to get the link for the group and find the admin for the same.

    #244012
    Henry Wright
    Moderator

    Good shout @shanebp.

    Also, looking at the groups_get_groupmeta() function definition, I’m wondering why we need to filter the query string with bp_filter_metaid_column_name?

    Anyway, alternatively, this may work but I haven’t tested:

    $retval = get_metadata( 'group', $group_id, $meta_key, $single );
    var_dump( $retval );

    Edit: Looks as though there is a reason BuddyPress uses bp_filter_metaid_column_name to filter the query. So my above might not work when it comes to BP.

    #243538
    coffeywebdev
    Participant

    Take a look at this code, I think it may be helpful for you…

    I created a function vp_add_group_activity_comments() that hooks to the ‘post_comment’ action, so when a user posts a comment an activity stream item is created and added to their group’s feed.. (on my site users can only be in one group at a time)

    It’s all about what you set for the $args array….

    
    function vp_add_group_activity_comments($comment_id){
    
    $comment = get_comment( $comment_id );
    GLOBAL $wpdb;
    $user_id = get_current_user_id();
    $user_info = get_userdata( $user_id );
    
    $current_user_group_id = $wpdb->get_var("SELECT group_id FROM ".$wpdb->prefix."bp_groups_members WHERE user_id = '".(int)$user_id."'");
    
    $comment_action = "<a href='".site_url()."/members/".$user_info->user_login."'>".$user_info->first_name." ".$user_info->last_name."</a> posted a comment on <a href='".get_permalink($comment->comment_post_ID )."'>".get_the_title($comment->comment_post_ID)."</a>";
    
    // arguments to pass to the bp_activity_add() function
    $args = array(
    'action'            => $comment_action,                     // The activity action - e.g. "Jon Doe posted an update"
    'content'           => $comment->comment_content,                     // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!"
    'component'         => 'groups',                  // The name/ID of the component e.g. groups, profile, mycomponent
    'type'              => 'activity_update',                  // The activity type e.g. activity_update, profile_updated
    'primary_link'      => get_permalink($comment->comment_post_ID ),                     // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink)
    'user_id'           => $user_id,  // Optional: The user to record the activity for, can be false if this activity is not for a user.
    'item_id'           => $current_user_group_id,                  // Optional: The ID of the specific item being recorded, e.g. a blog_id
    'secondary_item_id' => $comment->comment_ID,                  // Optional: A second ID used to further filter e.g. a comment_id
    'recorded_time'     => bp_core_current_time(), // The GMT time that this activity was recorded
    'hide_sitewide'     => 0,                  // Should this be hidden on the sitewide activity stream?
    'is_spam'           => 0,                  // Is this activity item to be marked as spam?
    );
    
    $add_activity = bp_activity_add($args);
    
    // Update the group's last activity
    groups_update_last_activity( $current_user_group_id );
    
    return true;
    }  
    add_action('comment_post', 'vp_add_group_activity_comments' );
    
    #243537
    coffeywebdev
    Participant

    Take a look at the code below to see how I use the post_comment action to hook my function vp_add_group_activity_comments(), which creates an activity stream item when a user posts a comment and adds it to their group’s activity stream… This is just what we are doing for our site, but if you look at the code you should be able to figure out how to do it for your site….

    
    function vp_add_group_activity_comments($comment_id){
    
    $comment = get_comment( $comment_id );
    GLOBAL $wpdb;
    $user_id = get_current_user_id();
    $user_info = get_userdata( $user_id );
    
    $current_user_group_id = $wpdb->get_var("SELECT group_id FROM ".$wpdb->prefix."bp_groups_members WHERE user_id = '".(int)$user_id."'");
    
    $comment_action = "<a href='".site_url()."/members/".$user_info->user_login."'>".$user_info->first_name." ".$user_info->last_name."</a> posted a comment on <a href='".get_permalink($comment->comment_post_ID )."'>".get_the_title($comment->comment_post_ID)."</a>";
    
    // arguments to pass to the bp_activity_add() function
    $args = array(
    'action'            => $comment_action,                     // The activity action - e.g. "Jon Doe posted an update"
    'content'           => $comment->comment_content,                     // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!"
    'component'         => 'groups',                  // The name/ID of the component e.g. groups, profile, mycomponent
    'type'              => 'activity_update',                  // The activity type e.g. activity_update, profile_updated
    'primary_link'      => get_permalink($comment->comment_post_ID ),                     // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink)
    'user_id'           => $user_id,  // Optional: The user to record the activity for, can be false if this activity is not for a user.
    'item_id'           => $current_user_group_id,                  // Optional: The ID of the specific item being recorded, e.g. a blog_id
    'secondary_item_id' => $comment->comment_ID,                  // Optional: A second ID used to further filter e.g. a comment_id
    'recorded_time'     => bp_core_current_time(), // The GMT time that this activity was recorded
    'hide_sitewide'     => 0,                  // Should this be hidden on the sitewide activity stream?
    'is_spam'           => 0,                  // Is this activity item to be marked as spam?
    );
    
    $add_activity = bp_activity_add($args);
    
    // Update the group's last activity
    groups_update_last_activity( $current_user_group_id );
    
    return true;
    }  
    add_action('comment_post', 'vp_add_group_activity_comments' );
    
    #242993
    Quinn Goldwin
    Participant

    ps I’ve tried all of these calls and still nothing

    if ( BP_Groups_Member::get_is_admin_of( $user_id )) {

    if ( ! groups_is_user_admin( $user_id, $group_id ) ) {

    if ( groups_is_user_admin( $user_id, $group_id ) ) {

    if ( groups_is_user_admin( get_current_user_id(), $group_id ) ) {

Viewing 25 results - 151 through 175 (of 564 total)
Skip to toolbar