Skip to:
Content
Pages
Categories
Search
Top
Bottom

Action for Removing Member from group

Viewing 7 replies - 1 through 7 (of 7 total)

  • @mercime
    Participant

    @mercime

    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?


    seppy
    Participant

    @seppy

    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' );


    @mercime
    Participant

    @mercime

    groups_remove_member


    seppy
    Participant

    @seppy

    ahh, thanks heaps! Couldn’t find that anywhere 🙂


    seppy
    Participant

    @seppy

    @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!


    seppy
    Participant

    @seppy

    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.


    ravibarnwal
    Participant

    @ravibarnwal

    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?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Action for Removing Member from group’ is closed to new replies.
Skip to toolbar