protected static function delete_user_data($userid) {
        global $DB;

        // Delete the stuff.
        $DB->delete_records('badge_manual_award', ['recipientid' => $userid]);
        $DB->delete_records('badge_criteria_met', ['userid' => $userid]);
        $DB->delete_records('badge_issued', ['userid' => $userid]);

        // Delete the backpacks and related stuff.
        $backpackids = $DB->get_fieldset_select('badge_backpack', 'id', 'userid = :userid', ['userid' => $userid]);
        if (!empty($backpackids)) {
            list($insql, $inparams) = $DB->get_in_or_equal($backpackids, SQL_PARAMS_NAMED);
            $DB->delete_records_select('badge_external', "backpackid $insql", $inparams);
            $DB->delete_records_select('badge_backpack', "id $insql", $inparams);
        }
    }
protected static function delete_user_data($userid) {
        global $DB;

        // Delete the stuff.
        $DB->delete_records('badge_manual_award', ['recipientid' => $userid]);
        $DB->delete_records('badge_criteria_met', ['userid' => $userid]);
        $DB->delete_records('badge_issued', ['userid' => $userid]);

        // Delete the backpacks and related stuff.
        $backpackids = $DB->get_fieldset_select('badge_backpack', 'id', 'userid = :userid', ['userid' => $userid]);
        if (!empty($backpackids)) {
            list($insql, $inparams) = $DB->get_in_or_equal($backpackids, SQL_PARAMS_NAMED);
            $DB->delete_records_select('badge_external', "backpackid $insql", $inparams);
            $DB->delete_records_select('badge_backpack', "id $insql", $inparams);
        }
    }
protected static function delete_user_data ( $ userid ) { global $ DB ; // Delete the stuff. $ DB -> delete_records ( 'badge_manual_award' , [ 'recipientid' => $ userid ] ) ; $ DB -> delete_records ( 'badge_criteria_met' , [ 'userid' => $ userid ] ) ; $ DB -> delete_records ( 'badge_issued' , [ 'userid' => $ userid ] ) ; // Delete the backpacks and related stuff. $ backpackids = $ DB -> get_fieldset_select ( 'badge_backpack' , 'id' , 'userid = :userid' , [ 'userid' => $ userid ] ) ; if ( ! empty ( $ backpackids ) ) { list ( $ insql , $ inparams ) = $ DB -> get_in_or_equal ( $ backpackids , SQL_PARAMS_NAMED ) ; $ DB -> delete_records_select ( 'badge_external' , "backpackid $insql" , $ inparams ) ; $ DB -> delete_records_select ( 'badge_backpack' , "id $insql" , $ inparams ) ; } }
Delete all the data for a user.

@param int $userid The user ID.
@return void
Delete all the data for a user .