Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 1 replies (of 1 total)

  • 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 1 replies (of 1 total)
Skip to toolbar