Skip to:
Content
Pages
Categories
Search
Top
Bottom

Remove all member from all group & redirect them to complete profile field


  • tesargusmawan
    Participant

    @tesargusmawan

    Hello,

    I use Buddypress for my college. Every semester the members (students) were automatically joined to the groups (courses) that they took using Groups-O-Matic Plugin. It is running as expected for now.
    What I want is, when the semester will be over, I want to remove all member from the groups (also the group admin) and reset their certain page of profile field that contains the list of group names (myurl…./profile/edit/group/3).
    So the members are forced to complete their profile field again and automatically joined the relevant groups as they complete their profile field for their next semester.

    I think that it is related to functions.php and header.php.

    Buddypress 1.8.1, WordPress 3.7.1

    This is what I have written in functions.php:

    /** Reset MatKul */
    if ( current_user_can( ‘administrator’ ) )
    { add_action(‘admin_bar_menu’, ‘admin_bar_reset_matkul’, 100); }

    function admin_bar_reset_matkul($admin_bar){
    $admin_bar->add_menu( array(
    ‘id’ => ‘reset-matkul’,
    ‘title’ => ‘Reset MatKul’,
    ‘href’ => ‘?reset_matkul=true’,
    ‘meta’ => array(
    ‘title’ => __(‘Reset Mata Kuliah’),
    //’onclick’ => ”,
    ),
    ));

    }

    function reset_matkul() {
    if (current_user_can(‘administrator’))
    {
    reset_matkul_111(); reset_matkul_222();
    }
    else
    { echo “<script>alert(‘Access Deny’);</script>”; }
    }
    function reset_matkul_111() {
    global $wpdb;
    $wpdb->query(” DELETE FROM wp_bp_xprofile_data WHERE field_id = ‘3’ and user_id <> ‘1’ “);
    echo “<script>alert(‘Reset Mata Kuliah Selesai’);</script>”;
    }
    function reset_matkul_222() {
    global $wpdb;
    $wpdb->query(” DELETE FROM wp_bp_groups_members WHERE user_id <> ‘1’ “);
    echo “<script>alert(‘Reset Group Selesai’);</script>”;
    }

    ** I also make a button on my backend admin bar on header.php for this function.

    Could you guys please help?

    Big thanks!

  • The topic ‘Remove all member from all group & redirect them to complete profile field’ is closed to new replies.
Skip to toolbar