Search Results for 'group_id'
-
AuthorSearch Results
-
January 20, 2018 at 11:33 am #270208
Henry 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.February 15, 2017 at 1:40 am #263782shanebp
Moderator>Am I on the right track?
This is wrong.
bp_get_group_id(get_current_user_id());
Look up that function to see how it is used.Ask LearnDash how to get the group id on the LearnDash screen that you want to use.
February 14, 2017 at 11:59 pm #263779Sergio Peña
ParticipantThank you for your response.
I did ask Learndash and they referred me to third party programmers.
Since I am using buddypress groups, I thought it was appropriate to ask here as well. Apologies if I was mistaken!
So would it be something like this:
add_shortcode('course_mentor','nex_course_mentor'); function nex_course_mentor($atts, $content = null){ if(!is_user_logged_in()) return; if(!bp_is_active('groups')) return; $nex_group_id = bp_get_group_id(get_current_user_id()); if(!empty($nex_group_id)){ foreach($nex_group_id as $nex_group_id){ $nex_admins = groups_get_group_admins( $nex_group_id ); foreach($admins as $admin){ ?> <a href="<?php echo bp_core_get_user_domain($admin->user_id) ?>" title="<?php echo bp_core_get_user_displayname( $admin->user_id, true ) ?>"> <?php echo bp_core_fetch_avatar ( array( 'item_id' => $admin->user_id, 'type' => 'thumb' ) ) ?></a>'; <?php } } } }I’m just copy/pasting and trying to connect a bunch of different answers together. As you can tell, I’m no coder.
Since each group may have more than one group leader/mentor I had a loop in there. Hopefully that will get the ball rolling on what I’m trying to do.
Am I on the right track?
February 14, 2017 at 11:45 pm #263778shanebp
ModeratorTry using
bp_get_group_id().
If you can get the group id, then usegroups_get_group_admins( $group_id )to get the group admins.
Pull out the user ids of the group admins and use the ids to get the user data that you want.NOTE: you should be asking LearnDash these questions.
By asking them here, you are asking volunteers to answer questions about a third-party premium plugin.
Therefore, you most likely won’t get much assistance here. -
AuthorSearch Results