Search Results for 'group_id'
-
AuthorSearch Results
-
February 3, 2019 at 12:26 pm #302589
shanebp
ModeratorTry something like:
$group_ids = groups_get_user_groups( bp_displayed_user_id() ); foreach( $group_ids["groups"] as $id ) { $group = groups_get_group( array( 'group_id' => $id) ); // var_dump( $group ); // see all the fields $link = bp_get_group_permalink( $group ); echo $link; }January 31, 2019 at 1:30 am #302496In reply to: Display the group id PHP ?
egamestudio
ParticipantResolved 🙂 LOL
Just change the $group_id = …. to bp_get_group_id()
January 15, 2019 at 2:38 pm #302233In reply to: Display Certain Profile Fields in Sidebar
webusat
ParticipantHi,
I am controlling what appears where by using this code:
<?php $groupid = bp_get_the_profile_group_id(); // enter group id in array if( in_array($groupid, array(1,2,3,4)) ) : ?>Stan
December 29, 2018 at 1:36 pm #283065In reply to: Producing array of group user ids
shanebp
ModeratorTry something like this in your shortcode:
$args = array( 'group_id' => 666, // set the ID somehow 'exclude_admins_mods' => false ); $group_members_result = groups_get_group_members( $args ); $group_members = array(); foreach( $group_members_result['members'] as $member ) { $group_members[] = $member->ID; } return implode(", ", $group_members);Check the
$argsby reviewinggroups_get_group_members()inbuddypress\bp-groups\bp-groups-functions.phpDecember 24, 2018 at 9:27 am #283007In reply to: Custom field validation to create group
pratibhasvaksha
Participantfunction group_header_fields_save( $group_id ) {December 14, 2018 at 11:19 am #282804In reply to: display groups members list (in all groups)
shanebp
ModeratorAs stated, the code is just an example of collecting the groups and group members.
You could put the code in a function and then call that function wherever you want.
For example, this could go in your theme > functions.php file :function diego_show_groups() { $args = array( 'show_hidden' => true, 'per_page' => -1 ); $groups = groups_get_groups( $args ); foreach ( $groups['groups'] as $group ) { $args = array( 'group_id' => $group->id, 'exclude_admins_mods' => false ); $members = groups_get_group_members( $args ); echo'<pre>'; var_dump( $members ); echo'</pre>'; // just for reference // do something with the member data } }Then in a template, you could put:
<?php diego_show_groups(); ?>Only you know exactly what you’re trying to do.
As I said: Where and when you place the data is up to you.December 1, 2018 at 6:11 pm #282414In reply to: display groups members list (in all groups)
shanebp
ModeratorWhere and when you place the data is up to you.
To gather the data, try :$args = array( 'show_hidden' => true, 'per_page' => -1 ); $groups = groups_get_groups( $args ); foreach ( $groups['groups'] as $group ) { $args = array( 'group_id' => $group->id, 'exclude_admins_mods' => false ); $members = groups_get_group_members( $args ); echo'<pre>'; var_dump( $members ); echo'</pre>'; // just for reference // do something with the member data }November 27, 2018 at 3:22 pm #282202In reply to: SHOW GROUPS ADMINS
shanebp
ModeratorYou can use this hook:
do_action( 'bp_directory_groups_item' );For example, this will display a link to the first admin for each group:
function diego_add_group_admin_info() { $group_id = bp_get_group_id(); $group_admins = groups_get_group_admins( $group_id ); $admin_id = $group_admins[0]->user_id; echo bp_core_get_userlink( $admin_id ); } add_action( 'bp_directory_groups_item', 'diego_add_group_admin_info' );October 23, 2018 at 12:21 pm #279363Topic: list of all groups
in forum How-to & Troubleshootingleandrorm
ParticipantI would like to force the action to the user ,
I am trying to get the list of all groups but is not working groups_get_groups ($args) and BP_Groups_Group:: get ($args); they come back with 0 groups how do I get all the groups on my db so that I can add them to the group if exist with groups_accept_invite ($user_id, $group_id);October 13, 2018 at 8:52 pm #278607In reply to: Profile field groups tabs while editing profile
Prashant Singh
ParticipantFirst replace the code for redirection with this code, remember that we have to just change the redirect code not the translation code.
function ps_redirect_next_group() { if ( ! bp_is_user_profile_edit() || ! bp_is_my_profile() ) { return; } $group_id = bp_get_current_profile_group_id()+1; if ( bp_get_current_profile_group_id()==6 ) { // 6 is the last group id, please change if it is anything else bp_core_redirect(bp_displayed_user_domain()."profile/"); }else{ bp_core_redirect(bp_displayed_user_domain()."profile/edit/group/$group_id/"); } } add_action( 'xprofile_updated_profile', 'ps_redirect_next_group' );And now to show the button:
add_action( 'bp_after_profile_edit_content' , 'ps_show_button_after_step'); function ps_show_button_after_step(){ if ( bp_get_current_profile_group_id()==4 ) { ?> <input type="button" name="profile" id="profile" onClick="window.location.href='<?php echo bp_displayed_user_domain()."profile/";?>'" value="Exit"/> <?php } }Thanks
October 10, 2018 at 8:09 pm #278455In reply to: Profile field groups tabs while editing profile
Prashant Singh
ParticipantHi,
No need to edit any template. I have created a snippet for you. Please paste the following snippet in your child theme’s functions.php file:
function ps_redirect_next_group() { if ( ! bp_is_user_profile_edit() || ! bp_is_my_profile() ) { return; } $group_id = bp_get_current_profile_group_id()+1; if ( bp_get_current_profile_group_id()==4 ) { bp_core_redirect(bp_displayed_user_domain()."profile/"); }else{ bp_core_redirect(bp_displayed_user_domain()."profile/edit/group/$group_id/"); } } add_action( 'xprofile_data_after_save', 'ps_redirect_next_group' ); add_filter( 'gettext', 'ps_change_save_button_text', 20, 3 ); function ps_change_save_button_text( $translated_text, $text, $domain ) { if ( ! bp_is_user_profile_edit() || ! bp_is_my_profile() ) { return $translated_text; } switch ( $translated_text ) { case 'Save Changes' : $translated_text = __( 'Save and Continue', $domain ); break; } return $translated_text; }If there is no child theme then create a file bp-custom.php in wp-content/plugins/ folder and paste this there. https://codex.buddypress.org/themes/bp-custom-php/
If not possible to create bp-custom.php file then third and easy solution is to install the plugin code snippets https://wordpress.org/plugins/code-snippets/ and there add a snippet and paste the code and save.
Hopefully, it will help you.
Thanks
October 9, 2018 at 7:00 pm #278397In reply to: Default Landing group while editing Member profile
Prashant Singh
Participantfunction ps_change_default_profile_group() { if ( ! bp_is_user_profile_edit() || ! bp_is_my_profile() ) { return; } $group_id = 2; if ( bp_get_current_profile_group_id()==1 ) { bp_core_redirect(bp_displayed_user_domain()."profile/edit/group/2/"); } } add_action( 'get_header', 'ps_change_default_profile_group', 1 );Hi, please remove what you did in edit.php and use this code. Try pasting this in bp-custom.php file. If not able to create then add a plugin called Code Snippets https://wordpress.org/plugins/code-snippets/ and then add a snippet and paste the code there.
Thanks
October 9, 2018 at 6:38 pm #278394In reply to: Default Landing group while editing Member profile
Bit Boy
ParticipantHi,
Here is another approach to solve the same issue./** * Change the profile edit landing group tab. */ function bitboy_change_landing_profile_group() { // are we on edit profile? if ( ! bp_is_user_profile_edit() || ! bp_is_my_profile() ) { return; } $group_id = 2; // Make sure a group is set. if ( ! bp_action_variable( 1 ) ) { bp_core_redirect( trailingslashit( bp_displayed_user_domain() . bp_get_profile_slug() . '/edit/group/'. $group_id ) ); } } add_action( 'bp_screens', 'bitboy_change_landing_profile_group', 2 );This does not requore any change in any template file.
September 1, 2018 at 12:51 am #276072In reply to: Display Group Mod Member Type
shanebp
ModeratorYour code is incomplete and does not appear to be germane to displaying member types.
Perhaps you meant to post something else.Anyhow –
You can usegroups_get_group_mods( $group_id )to get an array re the mods that includes their IDs.Then use
bp_get_member_type( $user_id )to get the member type.June 9, 2018 at 4:55 pm #274265In reply to: BP External Group RSS FEEDS: Thumbnail Images
quigley05
ParticipantHmm.. there is the following code that looks suspect in the plugin:
/* Fetch an existing activity_id if one exists. */ if ( function_exists( 'bp_activity_get_activity_id' ) ) $id = bp_activity_get_activity_id( array( 'user_id' => false, 'action' => $activity_action, 'component' => $bp->groups->id, 'type' => 'exb', 'item_id' => $group_id, 'secondary_item_id' => wp_hash( $post['blogurl'] ) ) );Anything here stand out as a possibility?
Also, regarding the thumbnail integration, I’ve been trying to figure out what the necessary fetching rules are to gather that data? The below is clearly where it goes, I just have no clue how to properly integrate this..
/* Set the visibility */ $hide_sitewide = ( 'public' != $group->status ) ? true : false; foreach ( (array) $group_blogs as $feed_url ) { $rss = fetch_feed( trim( $feed_url ) ); if (!is_wp_error($rss) ) { $maxitems = $rss->get_item_quantity( 10 ); $rss_items = $rss->get_items( 0, $maxitems ); foreach ( $rss_items as $item ) {; $key = $item->get_date( 'U' ); $items[$key]['title'] = $item->get_title(); $items[$key]['subtitle'] = $item->get_title(); //$items[$key]['author'] = $item->get_author()->get_name(); $items[$key]['blogname'] = $item->get_feed()->get_title(); $items[$key]['link'] = $item->get_permalink(); $items[$key]['blogurl'] = $item->get_feed()->get_link(); $items[$key]['description'] = $item->get_description(); $items[$key]['source'] = $item->get_source(); $items[$key]['copyright'] = $item->get_copyright(); } } } if ( $items ) { ksort( $items ); $items = array_reverse( $items, true ); } else { return false; } /* Record found blog posts in activity streams */ foreach ( (array) $items as $post_date => $post ) { $activity_action = sprintf( __( '%s from %s in %s', 'bp-groups-externalblogs' ), '<a class="feed-link" href="' . esc_attr( $post['link'] ) . '" target="_blank">' . esc_attr( $post['title'] ) . '</a>', '<a class="feed-author" href="' . esc_attr( $post['blogurl'] ) . '" target="_blank">' . attribute_escape( $post['blogname'] ) . '</a>', '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ); $activity_content = '<div>' . strip_tags( bp_create_excerpt( $post['description'], 175 ) ) . '</div>'; $activity_content = apply_filters( 'bp_groupblogs_activity_content', $activity_content, $post, $group ); /* Fetch an existing activity_id if one exists. */ if ( function_exists( 'bp_activity_get_activity_id' ) ) $id = bp_activity_get_activity_id( array( 'user_id' => false, 'action' => $activity_action, 'component' => $bp->groups->id, 'type' => 'exb', 'item_id' => $group_id, 'secondary_item_id' => wp_hash( $post['blogurl'] ) ) ); /* Record or update in activity streams. */ groups_record_activity( array( 'id' => $id, 'user_id' => false, 'action' => $activity_action, 'content' => $activity_content, 'primary_link' => $item->get_link(), 'type' => 'exb', 'item_id' => $group_id, 'secondary_item_id' => wp_hash( $post['blogurl'] ), 'recorded_time' => gmdate( "Y-m-d H:i:s"), 'hide_sitewide' => $hide_sitewide ) ); } return $items; }Venutius
ModeratorAh you mean:
$groups = BP_Groups_Member::get_group_ids( $user_id, $per_page );?
Venutius
ModeratorThe infor is help in _bp_groups_members, there’s a group_id and a user_id meta key
May 23, 2018 at 10:12 am #273369In reply to: Comment Button and Reply Not showing
Varun Dubey
Participant@cyberjulie you can download the previous version at https://downloads.wordpress.org/plugin/buddypress.2.9.4.zip
@abracarambar patch is working fine, you only need to modify
Line 395 inside plugins/buddypress/bp-groups/bp-groups-activity.php( ! groups_is_user_member( bp_loggedin_user_id(), $group_id ) || ! groups_is_user_banned( bp_loggedin_user_id(), $group_id ) )
with
( ! groups_is_user_member( bp_loggedin_user_id(), $group_id ) || groups_is_user_banned( bp_loggedin_user_id(), $group_id ) )May 20, 2018 at 1:46 pm #273221In reply to: add user to group when user is added via dashboard
Paul Wong-Gibbs
Keymaster@anrahulpandey Check the function declaration for
groups_join_group()inside BuddyPress’ files!function groups_join_group( $group_id, $user_id = 0 )I think you are specifying the user_id and group_id parameters in the wrong order. 🙂
May 4, 2018 at 4:45 pm #272723In reply to: altering the user search query
louie171
Participantupdate: I wrote the code. It all seems to work fine (except), it doesn’t seem to affect the query (i.e. the results in members index page are not right). Not sure why ?
Any input would be hugely appreciated:
function add_groups_to_members_search( $query_args ) { $search = esc_sql($_REQUEST['search_terms']); // search box on members index page global $wpdb; // get users in groups that search term is like $sql = "SELECT m.user_id FROM wp_bp_groups g, wp_bp_groups_members m where g.id = m.group_id and g.name like '%$search%'"; $myrows = $wpdb->get_results( $sql ); $user_ids = array(); foreach ($myrows as $obj ) { $user_ids[] = $obj->user_id; } $query_args['include'] = $user_ids; return $query_args; } add_filter( 'bp_before_has_members_parse_args', 'add_groups_to_members_search', 999999, 1 );April 17, 2018 at 10:56 am #272171In reply to: Get group meta value without filter
luice
Participantremove_filter('the_content', 'do_shortcode', 11); $setting = groups_get_groupmeta( $group_id, 'group_resources_setting');April 2, 2018 at 6:03 pm #271696Venutius
ModeratorThe following change will remove the What’s New area from the Activity page, it will still be visible in Groups and on the users profile activity page.
You will need to set up a childtheme (there’s plenty of plugins that will do this for you).
<?php /** * BuddyPress - Activity Post Form * * @package BuddyPress * @subpackage bp-legacy */ ?> <form action="<?php bp_activity_post_form_action(); ?>" method="post" id="whats-new-form" name="whats-new-form"> <?php /** * Fires before the activity post form. * * @since 1.2.0 */ do_action( 'bp_before_activity_post_form' ); if ( bp_is_my_profile() || bp_is_group() ) : ?> <div id="whats-new-avatar"> <a href="<?php echo bp_loggedin_user_domain(); ?>"> <?php bp_loggedin_user_avatar( 'width=' . bp_core_avatar_thumb_width() . '&height=' . bp_core_avatar_thumb_height() ); ?> </a> </div> <p class="activity-greeting"><?php if ( bp_is_group() ) printf( __( "What's new in %s, %s?", 'buddypress' ), bp_get_group_name(), bp_get_user_firstname( bp_get_loggedin_user_fullname() ) ); else printf( __( "What's new, %s?", 'buddypress' ), bp_get_user_firstname( bp_get_loggedin_user_fullname() ) ); ?></p> <div id="whats-new-content"> <div id="whats-new-textarea"> <label for="whats-new" class="bp-screen-reader-text"><?php /* translators: accessibility text */ _e( 'Post what\'s new', 'buddypress' ); ?></label> <textarea class="bp-suggestions" name="whats-new" id="whats-new" cols="50" rows="10" <?php if ( bp_is_group() ) : ?>data-suggestions-group-id="<?php echo esc_attr( (int) bp_get_current_group_id() ); ?>" <?php endif; ?> ><?php if ( isset( $_GET['r'] ) ) : ?>@<?php echo esc_textarea( $_GET['r'] ); ?> <?php endif; ?></textarea> </div> <div id="whats-new-options"> <div id="whats-new-submit"> <input type="submit" name="aw-whats-new-submit" id="aw-whats-new-submit" value="<?php esc_attr_e( 'Post Update', 'buddypress' ); ?>" /> </div> <?php if ( bp_is_active( 'groups' ) && !bp_is_my_profile() && !bp_is_group() ) : ?> <div id="whats-new-post-in-box"> <?php _e( 'Post in', 'buddypress' ); ?>: <label for="whats-new-post-in" class="bp-screen-reader-text"><?php /* translators: accessibility text */ _e( 'Post in', 'buddypress' ); ?></label> <select id="whats-new-post-in" name="whats-new-post-in"> <option selected="selected" value="0"><?php _e( 'My Profile', 'buddypress' ); ?></option> <?php if ( bp_has_groups( 'user_id=' . bp_loggedin_user_id() . '&type=alphabetical&max=100&per_page=100&populate_extras=0&update_meta_cache=0' ) ) : while ( bp_groups() ) : bp_the_group(); ?> <option value="<?php bp_group_id(); ?>"><?php bp_group_name(); ?></option> <?php endwhile; endif; ?> </select> </div> <input type="hidden" id="whats-new-post-object" name="whats-new-post-object" value="groups" /> <?php elseif ( bp_is_group_activity() ) : ?> <input type="hidden" id="whats-new-post-object" name="whats-new-post-object" value="groups" /> <input type="hidden" id="whats-new-post-in" name="whats-new-post-in" value="<?php bp_group_id(); ?>" /> <?php endif; ?> <?php /** * Fires at the end of the activity post form markup. * * @since 1.2.0 */ do_action( 'bp_activity_post_form_options' ); ?> </div><!-- #whats-new-options --> </div><!-- #whats-new-content --> <?php wp_nonce_field( 'post_update', '_wpnonce_post_update' ); ?> <?php /** * Fires after the activity post form. * * @since 1.2.0 */ endif; do_action( 'bp_after_activity_post_form' ); ?> </form><!-- #whats-new-form -->Just place this file content in your themes/child-theme/buddypress/activity/post-form.php file. Activity, replacing everything that’s in the current file.
If you want an easier way to manage your template overloads you should look at BP Template Overloader, which will help you keep track. When you overload a theme page, you need to remember that you will have to take responsibility for keeping it up to date since any changes to the master file will no longer be loaded.
February 20, 2018 at 10:10 pm #270932In reply to: Buddypress Group Extension API Not Working
ethanstein
ParticipantYes, definitely helpful. Any idea how to implement the solution within the groups index page as a bulk option as oppose to having to go into the individual group?
I tried using wordpress’s bulk admin similar to the example pertaining to load-users.php, but it isn’t working.
add_filter( 'handle_bulk_actions-toplevel_page_bp-groups', 'add_bpgroups_to_bpgroup', 10, 3 ); function add_bpgroups_to_bpgroup($redirect_to, $doaction, $group_ids) { trigger_error($doaction); trigger_error($redirect_to); if( bp_is_active('groups') ): if ( $doaction !== 'assign_parent_group' ) { return $redirect_to; } trigger_error(print_r($group_ids,TRUE)); $redirect_to = add_query_arg( 'groups_assigned' , implode(',', $group_ids) , $redirect_to ); endif; return $redirect_to; } add_filter( 'bulk_actions-toplevel_page_bp-groups', 'register_bulk_assign_parent_action' ); function register_bulk_assign_parent_action ($bulk_actions) { $bulk_actions['assign_parent_group'] = __( 'Assign Parent Group', 'assign_parent_group'); //form submission add_action( 'admin_footer', function() { ?> <script type="text/javascript" charset="utf-8"> jQuery("#doaction").click(function(e){ if(jQuery("select[name='action'] :selected").val()=="assign_parent_group") { e.preventDefault(); gid=prompt("Enter a Group ID","1"); if (gid != null) { jQuery(".wrap form").append('<input type="hidden" name="bp_gid" value="'+gid+'" />').submit(); } } }); </script> <?php }); return $bulk_actions; } add_action( 'admin_notices', 'bulk_assign_parent_action_admin_notice' ); function bulk_assign_parent_action_admin_notice() { if ( ! empty( $_REQUEST['groups_assigned'] ) && ! empty( $_REQUEST['assigned_group'] ) ) { $groups_assigned = $_REQUEST['groups_assigned'] ; $parent_id = $_REQUEST['assigned_group']; $parent_group = groups_get_group($parent_id); if ($parent_group->id == 0) { printf( '<div id="message" class="error">Unknown group ID %s</div>', $parent_id); return; } $group_ids = explode(',' , $groups_assigned); foreach ($group_ids as $group_id) { $group = groups_get_group( $group_id ); if (false === groups_edit_group_settings($group_id, $group->enable_forum, $group->status, false, $parent_id )) { printf( '<div id="message" class="error">Failed to add group %s to %s.</div>', $group->name, $parent_group->name); break; } } printf( '<div id="message" class="updated fade">Successfully ' . _n( 'assigned %s group', 'assigned %s groups', $groups_assigned, 'assign_parent_group' ) . 'to %s</div>', $groups_assigned, $group_name ); }It fires the
add_filter( ‘bulk_actions-toplevel_page_bp-groups’, ‘register_bulk_assign_parent_action’ );correctly but seems to completely ignore
add_filter( ‘handle_bulk_actions-toplevel_page_bp-groups’, ‘add_bpgroups_to_bpgroup’, 10, 3 );
Any ideas?
February 7, 2018 at 9:58 am #270641amiya36
Participantmy error log?
WordPress database error Unknown column ‘profile’ in ‘where clause’ for query SELECT a.* FROM wp_buddyboss_media_albums a WHERE a.user_id=886 AND ( a.group_id NOT IN ( SELECT id FROM wp_bp_groups WHERE status != ‘public’ )
OR a.group_id IS NULL ) AND ( a.privacy IN ( ‘public’) ) AND a.id IN (profile) ORDER BY a.date_created DESC LIMIT 0, 20 made by require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), include(‘/themes/woffice/buddypress.php’), the_content, apply_filters(‘the_content’), WP_Hook->apply_filters, bp_replace_the_content, apply_filters(‘bp_replace_the_content’), WP_Hook->apply_filters, BP_Members_Theme_Compat->single_dummy_content, bp_buffer_template_part, bp_get_template_part, bp_locate_template, load_template, require(‘/themes/woffice/buddypress/members/single/home.php’), bp_get_template_part, bp_locate_template, load_template, require(‘/themes/woffice/buddypress/members/single/plugins.php’), do_action(‘bp_template_content’), WP_Hook->do_action, WP_Hook->apply_filters, buddyboss_media_template_albums, buddyboss_media_load_template, include_once(‘/plugins/buddyboss-media/templates/members/single/buddyboss-media-album.php’), buddyboss_media_has_albums, BuddyBoss_Media_Albums->__construct, BuddyBoss_Media_Albums->fetch_albumsJanuary 26, 2018 at 4:20 pm #270345ToobHed
ParticipantI’m not sure why I would need to hook to something? I am running this process independently as part of a currently working cron job. I want to add a routine to my cron job that would remove users from groups if they are of a certain role. I have everything working, except I am not able to find the groups a user belongs to. I believe the code $group_ids = BP_Groups_Member::get_group_ids( $user_id ); is correct since I get the intended results when I run this from the buddypress page for members. That page must contain all the necessary declarative and required components. When I run the same code in functions.php even supplying a known user id such as $group_ids = BP_Groups_Member::get_group_ids( 2); my array is empty. Furthermore I get the errors noted above that I do not get when running this code from the members page.
-
AuthorSearch Results