You don’t want to remove the member via single Group > Admin > Members? Or are you considering removing a handful of members from the group/s?
Hi @mercime ,
What I am doing is when a User gets accepted into a group I’m automatically assigning them a set of permissions as well through an attached function.
add_action( 'groups_membership_accepted', 'my_function' );
But when someone is being removed from a group (through Group > Admin > Members) I can’t seem to find the action for that.
add_action( 'groups_membership_removed?', 'my_other_function' );
ahh, thanks heaps! Couldn’t find that anywhere đ
@mercime
Sorry, have one more question! Stuck on a similar issue again, the groups_remove_member worked a treat :), but I also need to hook a function for when a person clicks “leave group” on their own accord.
`add_action( ‘groups_leave_group‘, ‘function_here’ );`
I tried ‘groups_leave_group’ but this doesn’t seem to work (unless I’m doing something stupid).
Also I was wondering if you could clear up what the “screen” means in the actions like groups_screen_group_forum
groups_screen_group_members
groups_screen_group_invite
groups_screen_group_leave
Really appreciate your help so far!
Can’t seem to get this working, I’ll just disable the ability to let people leave for now (so they can only be removed by admin). Doesn’t matter too much as the site is only private groups.
groups_remove_member how to used in my plugin I am not able to used it.
Please explain .
I want to remove member from a group when new user registered.
I have received group_id and user_id from database. then I want to remove all member from that group without group admin.
I used function âgroups_remove_memberâ in my own plugin .
I am new in wordpress and buddypress coding.
My code is
if (!function_exists(âauto_joinâ)) {
function update_auto_join_status($user_id) {
global $wpdb, $bp;
// get list of groups to auto-join.
$group_list = $wpdb->get_results(âSELECT * FROM {$bp->groups->table_name} WHERE auto_join = 1âł);
foreach ($group_list as $group_auto_join) {
$members_count = groups_get_groupmeta( $group_auto_join->id, âtotal_member_countâ );
if($members_count < 5)
{
groups_accept_invite( $user_id, $group_auto_join->id );
}
else
{
group_auto_join_hidden_group($user_id, $group_auto_join->id);
}
}
$wpdb->query(âUPDATE {$wpdb->users} SET auto_join_complete = 1 WHERE ID = {$user_id}â);
}
add_action( âuser_registerâ, âauto_joinâ);
}
function group_auto_join_hidden_group($user_id, $group_id)
{
global $wpdb, $bp;
$utn = $wpdb->users; // Create a shortcut variable for wordpress users table.
$gmtn = $bp->groups->table_name . â_membersâ; // Create a shortcut variable for buddypress groups_members table.
$mysql = âSELECT user_id FROM $gmtn WHERE group_id=$group_idâ;
$results = $wpdb->get_results( $mysql);
foreach ( $results as $user) {
groups_remove_member($user->user_id, $group_id);
}
}
my auto join working well but I am not able to remove member
Please help me what is wrong?