Search Results for 'group_id'
-
AuthorSearch Results
-
February 20, 2018 at 10:10 pm #270932
In 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.
January 20, 2018 at 11:33 am #270208Henry Wright
ModeratorYou’re using the class method properly. This should output an array containing an array of groups and a count.
$group_ids = BP_Groups_Member::get_group_ids( $user_id ); var_dump( $group_ids );Make sure the
$user_idargument you are passing to the class method is valid. It should be an integer but I don’t think type is enforced in this case so a string might also work.January 9, 2018 at 3:09 pm #270035In reply to: Adding Groups to Mailchimp Sync
Peter Hardy-vanDoorn
Participantbp_get_current_group_id()gets the ID of the current group, not the groups to which the user is a member of.For that you need
groups_get_user_groups().It will return an array of group info, so you’ll have to process it further before storing it.
Have a look here: http://hookr.io/functions/groups_get_user_groups/
January 6, 2018 at 4:27 pm #269954Renato Alves
ModeratorYou can certainly use BuddyPress WP CLI for that: https://github.com/buddypress/wp-cli-buddypress
It has a
wp bp group membercommand.Something like
wp bp group member remove --group-id={GROUP_ID} --user-id={MEMBER_ID}December 14, 2017 at 3:53 pm #269572In reply to: Group. Custom page
Peter Hardy-vanDoorn
ParticipantHere’s the bare basic code to add a page to all groups:
class my_group_page extends BP_Group_Extension { function __construct() { $args = array( 'slug' => 'page_slug', 'name' => 'Page Name', 'nav_item_position' => 12 ); parent::init( $args ); } function display( $group_id = NULL ) { // page code goes here } } bp_register_group_extension( 'my_group_page' );November 28, 2017 at 2:53 am #269189In reply to: [Fixed] I can’t create groups page keeps reloading
Boone Gorges
KeymasterA few things to check:
1. After submitting the first page of the group creation process, is the group actually created in the database? Check Dashboard > Groups, or the
wp_bp_groupsdatabase table if you know how.2. Check your browser cookies to see if the
bp_new_group_idandbp_completed_create_stepscookies are set. If so, please share the details, especially the Domain and Path.3. If you have access to PHP error logs on your server, please check them for related errors. Otherwise, consider enabling
WP_DEBUGto see if anything relevant is shown after submitting the first step of the creation process.November 23, 2017 at 9:29 am #269127In reply to: Display groups of connected member
AliceG
ParticipantThank you for your reply.
Actually, I have a button “My group” and a none display bloc where I put this code, and a jquery shows all my groups on clic :<?php $group_ids = groups_get_user_groups(bp_displayed_user_id()); foreach($group_ids["groups"] as $group_id) { echo('<a title="Aller sur le groupe" href="' . home_url() . '/groupes/' . groups_get_group(array( 'group_id' => $group_id )) -> slug . '">' .groups_get_group(array( 'group_id' => $group_id )) -> name . '</a>' . (end($group_ids["groups"]) == $group_id ? '' : ', ' ) ); } ?>So this code is working on my profile page, I have all my groups. On a group page, only the group where I am shows, and everywhere else there is no list.
So do you have an idea to show a list of “my group” everywhere?
Thank you a lot !November 8, 2017 at 2:39 am #268881In reply to: Different sidebars for groups
Boone Gorges
KeymasterHi @hlubi – Generally, the sidebar is controlled by the WP theme you’re using. See sidebar.php. You’ll likely need to make your modifications in that file (probably in a child theme, if you’re not already using one).
Exactly what modifications you make depends heavily on how you want the sidebars to differ. If you have a small number of groups, and you want the sidebar to be totally customized for each one, sidebar.php might look something like this:
if ( bp_is_group() ) { $group_id = bp_get_current_group_id(); switch ( $group_id ) { case 1 : // group 1 sidebar break; case 2 : // group 2 sidebar break; } } else { // existing sidebar code }You could even register separate sidebars for each group, so that they can be managed separately in wp-admin. (This solution obviously won’t work well if you have lots and lots of groups.)
If you just want to have some group-specific content in the sidebar, you can use BP’s “current group” functions in sidebar.php. For example:
if ( bp_is_group() ) { $current_group = groups_get_current_group(); printf( 'This is the sidebar for group %s', esc_html( $current_group->name ) ); }This way, you’d have the same *type* of data on each group’s sidebar, but the specific data would be pulled dynamically based on which group is being shown.
September 20, 2017 at 3:28 pm #268142In reply to: Slider or list of members of a group
shanebp
ModeratorTry 0 instead of false:
<?php if (bp_group_has_members ('group_id=1&per_page=20&exclude_admins_mods=0')) : ?>Re layout: you’ll have to check those functions for filter hooks and use those to adjust layout. Or make your own calls.
September 20, 2017 at 10:14 am #268135In reply to: Slider or list of members of a group
J.Parra
ParticipantThank you very much for your quick response, it works almost perfect.
You can see it here: http://www.racingonlineclub.com/#agradecimientos
First of all I can not include administrators and moderators.
Is not this correct?
<? php if (bp_group_has_members (‘group_id = 1 & per_page = 20 & exclude_admins_mods = false’)):?>
And secondly I would like the name “bp_group_member_link” to appear under the avatar to better organize the grid.
Is this possible?
Currently the list is:
<li style = “display: inline;”>
      <! – Example template tags you can use ->
      <? php bp_group_member_avatar ()?>
      <? php bp_group_member_link ()?>
    </ li>Thanks again.
September 19, 2017 at 9:04 pm #268127In reply to: Slider or list of members of a group
shanebp
ModeratorUse
bp_group_has_membersand specific the id of the group.
For example:<php if ( bp_group_has_members( 'group_id=15' ) ) : ?>etc.September 5, 2017 at 8:46 pm #267892In reply to: how to hook after promote and demote user
MSoliman
Participanti’m using the buddypress groups to add a user role to members in the same group .. i hook into the
groups_member_after_savetoadd the role , which means when the user become a member he get the role .. andgroups_member_before_removeto remove the role ,when the user leave the group the role been removed. my code is working like charm now . what i need is , to add this role when the user become admin to the group , and remove the role when he be demoted to mod or member, or be banned or removed.. this is my current code , to add the role to joined members:function bpmp_add_member($bp_group_admin) { $bp_group = _bpmp_get_group($bp_group_admin->group_id); $user = new WP_User($bp_group_admin->user_id); $user->add_role(_bpmp_get_role($bp_group)); } function bpmp_remove_member($bp_group_admin) { $bp_group = _bpmp_get_group($bp_group_admin->group_id); $user = new WP_User($bp_group_admin->user_id); $user->remove_role(_bpmp_get_role($bp_group)); } add_action('groups_member_after_save', 'bpmp_add_member', 90, 1); add_action('groups_member_before_remove', 'bpmp_remove_member', 10, 1);i just need to know what’s the right hooks to use .. i found these hooks but don’t know how to use its functions parameters with the code above
// define the groups_promote_member callback function action_groups_promote_member( $group_id, $user_id, $status ) { // make action magic happen here... }; // add the action add_action( 'groups_promote_member', 'action_groups_promote_member', 10, 3 );// define the groups_demote_member callback function action_groups_demote_member( $group_id, $user_id ) { // make action magic happen here... }; // add the action add_action( 'groups_demote_member', 'action_groups_demote_member', 10, 2 );any help will be highly appreciated
September 2, 2017 at 5:17 am #267826In reply to: Checking for user role before group join
shanebp
ModeratorThe answer is right below the definition of the hook:
// The following properties are required; bail if not met. if ( empty( $this->user_id ) || empty( $this->group_id ) ) { return false; }Just delete the value for one of those fields.
August 31, 2017 at 9:21 am #267803In reply to: Hide a group of Profile Fields
artempr
ParticipantHi. If it still an issue , I d recommend you to look at bp-xprofile-settings.php
function bp_xprofile_get_settings_fields( $args = '' ) { //if u have ome custom user roles you can simply filter here which groups to hide if(!current_user_can("owner")){ $query='5,6,4'; }else{ $query='1,3,4,5'; } // Parse the possible arguments. $r = bp_parse_args( $args, array( 'user_id' => bp_displayed_user_id(), 'profile_group_id' => false, 'hide_empty_groups' => false, 'hide_empty_fields' => false, 'fetch_fields' => true, 'fetch_field_data' => false, 'fetch_visibility_level' => true, 'exclude_groups' => $query, 'exclude_fields' => false ), 'xprofile_get_settings_fields' ); return bp_has_profile( $r ); }July 21, 2017 at 1:45 pm #267130In reply to: Show members list in private group
bambidotexe
ParticipantI found a workaround, I’am quite not completely satisfied but…
First of all, disable members list on group:
function change_access_group_nav_tabs() { if(bp_is_group()) { buddypress()->groups->nav->edit_nav( array( 'user_has_access' => false ), 'members', bp_current_item() ); } } add_action( 'bp_actions', 'change_access_group_nav_tabs' );(btw, setting the value to true actually make the the nav items always here, but we still can’t access the group list on click)
And then I simply add a custom BP Group Extension to make my own members list:
class Group_Extension_List_Members extends BP_Group_Extension { /** * Here you can see more customization of the config options */ function __construct() { $args = array( 'slug' => 'members-list', 'name' => 'Membres', 'access' => array( 'anyone'), 'show_tab' => array( 'anyone'), 'nav_item_position' => 12, 'screens' => array( 'create' => array( 'enabled' => false ), 'edit' => array( 'enabled' => false ), ) ); parent::init( $args ); } function display( $group_id = NULL ) { //Remove user who do not belong to the group on members loop function filter_for_groups( $members_template_has_members, $members_template, $r ) { for ($i=sizeof($members_template->members)-1; $i >= 0 ; $i--) { $user_id = $members_template->members[$i]->id; if(!groups_is_user_member( $user_id, bp_get_group_id() )){ $members_template->member_count = $members_template->member_count-1; array_splice($members_template->members, $i, 1); } } if ($members_template->member_count <= 0) { return ''; } else { return $members_template_has_members; } }; add_filter( 'bp_has_members', 'filter_for_groups', 10, 3 ); require('/Your/theme/custom/members/loop/members-loop.php'); } } bp_register_group_extension( 'Group_Extension_List_Members' );Hope it will help other in the future, And I’m still open to know the good way to proceed.
July 4, 2017 at 1:14 pm #266841In reply to: Please help with activity comments
Brajesh Singh
ParticipantHi,
Please put the following code to your bp-custom.php/** * Step 1: Store the group id in meta when there is a new comment. */ function buddydev_store_group_in_activity_meta( $comment_id, $r, $activity ) { if ( $activity->component != 'groups' ) { return; } bp_activity_update_meta( $comment_id, '_group_id', $activity->item_id ); } // hook to comment posted action add_action( 'bp_activity_comment_posted', 'buddydev_store_group_in_activity_meta', 10, 3 ); add_action( 'bp_activity_comment_posted_notification_skipped', 'buddydev_store_group_in_activity_meta', 10, 3 ); //Filter the action string for comment and display it. function buddydev_add_group_link_in_activity_comment_action( $action, $activity ) { $group_id = bp_activity_get_meta( $activity->id, '_group_id', true ); if ( ! $group_id ) { return $action; } $group = new BP_Groups_Group( $group_id ); if ( ! $group->id ) { return $action; } $action = $action . sprintf( " in group <a href='%s'>%s</a>", bp_get_group_permalink( $group ), bp_get_group_name( $group ) ); return $action; } add_filter( 'bp_activity_comment_action', 'buddydev_add_group_link_in_activity_comment_action', 10, 2 );It records the group id in activity meta and uses that for displaying the group link.
Please do note that it will only work for newer comments.
Hope that helps.
April 7, 2017 at 2:59 pm #265307In reply to: Update Group name with Gravity Forms
hept27
ParticipantAsk and ye shall receive. I figured it out, though I’m sure its not the cleanest solution:
I created this function from the original “groups_edit_base_group_details” function
function bg_new_groups_edit_base_group_details( $group_id, $group_name, $group_desc, $notify_members ) { global $bp; if ( empty( $group_name ) || empty( $group_desc ) ) return false; $group = new BP_Groups_Group( $group_id ); $group->name = $group_name; $group->description = $group_desc; if ( !$group->save() ) return false; if ( $notify_members ) { groups_notification_group_updated( $group_id, $group_id, false ); } do_action( 'groups_details_updated', $group_id, $group_id, false ); return true; }Then I put the following code in a gravity forms gform_after_submission action:
$group_id = 2; $group_name = 'New NEw TEST'; $group_desc = 'testing description'; bg_new_groups_edit_base_group_details($group_id, $group_name, $group_desc, false);This is the proof of concept the finished product will look a little different but function the same.
April 4, 2017 at 3:01 pm #265239In reply to: Edit/delete xprofile fields (Multisite)
Schweizer Solutions GmbH
ParticipantWe’ve the same problem.
But we found a solution to fix it.
File: \htdocs\wp-content\plugins\buddypress\bp-xprofile\bp-xprofile-admin.php
Search the function “xprofile_admin_field” and there you replace the code from Line 609 to 630 with this:
$field_edit_url = add_query_arg( array( 'page' => 'bp-profile-setup', 'group_id' => (int) $field->group_id, 'field_id' => (int) $field->id, 'mode' => 'edit_field' ), //network_admin_url( 'users.php' ) 'users.php' ); if ( $field->can_delete ) { $field_delete_url = add_query_arg( array( 'page' => 'bp-profile-setup', 'field_id' => (int) $field->id, 'mode' => 'delete_field' ), //network_admin_url( 'users.php' ) . '#tabs-' . (int) $field->group_id 'users.php#tabs-' . (int) $field->group_id ); }So it don’t create nework admin url links, just site links. This will fix it till the next update.
I hope the BuddyPress devs will fix it in the next release 😉March 29, 2017 at 9:18 pm #265072mikeboltonca
ParticipantI’ve submitted an enhancement Trac here: https://buddypress.trac.wordpress.org/ticket/7489#ticket.
In the meantime, I’ve implemented the following hack to allow non-members to post on a group’s activity stream:
In/plugins/buddypress/bp-groups/bp-groups-functions.php, comment out lines 1215 and 1216.Original:
if ( !bp_current_user_can( 'bp_moderate' ) && !groups_is_user_member( $user_id, $group_id ) ) return false;Hacked:
//if ( !bp_current_user_can( 'bp_moderate' ) && !groups_is_user_member( $user_id, $group_id ) ) //return false;This removes the check for “Is this an admin or a group member?”, allowing anyone to post.
March 6, 2017 at 11:24 pm #264537In reply to: List of Group Member IDs
shanebp
ModeratorTry, after
while ( bp_groups() ) : bp_the_group();:$args = array( 'group_id' => bp_get_group_id(), '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; } echo implode(", ", $group_members);February 27, 2017 at 2:30 pm #264212In reply to: get events
Henry Wright
ModeratorTry this:
$args = array( 'meta_key' => 'group_id', 'meta_value' => '1', 'meta_compare' => '=', 'post_type' => 'event', 'posts_per_page' => -1 ); $query = new WP_Query( $args ); if ( $query->have_posts() ) { // Events } else { // No events }February 22, 2017 at 4:54 am #264030In reply to: Display activity of a specific group
danbp
ParticipantHi,
you have to use a group_id and to ensure you’re in an appropriate loop (activity or group)
To get a group id, you can for ex. do:
// check for a group ID if( bp_has_groups() ) { // Grab current group ID bp_the_group(); $group_id = bp_get_group_ID(); } // apply our changes only to this group ID's // conditionnal action if ( $group_id == 22 OR $group_id == 8 ) {… and so on!
You may also use bp_parse_args, depending where you use your custom work. In other words, you can create a complete new activity loop on a distinct page template for only one group.
February 21, 2017 at 9:49 pm #264015In reply to: create xprofile fields from plugin
Henry Wright
ModeratorI believe
xprofile_insert_field()will insert or update a profile field. Here’s an example of how to use it:$f = xprofile_insert_field( array( 'field_group_id' => 8, 'type' => 'textbox', 'name' => 'Foo', 'is_required' => false, 'can_delete' => false, 'description' => 'This is a description.' ) );On success,
$fwill be the ID of the new field. -
AuthorSearch Results