protected static function delete_all_user_data(context_user $usercontext) {
        global $DB;
        $userid = $usercontext->instanceid;

        // Delete all blog posts.
        $recordset = $DB->get_recordset_select('post', 'userid = :userid AND module IN (:blog, :blogext)', [
            'userid' => $userid, 'blog' => 'blog', 'blogext' => 'blog_external']);
        foreach ($recordset as $record) {
            $entry = new blog_entry(null, $record);
            $entry->delete();   // Takes care of files and associations.
        }
        $recordset->close();

        // Delete all external blogs, and their associated tags.
        $DB->delete_records('blog_external', ['userid' => $userid]);
        core_tag_tag::delete_instances('core', 'blog_external', $usercontext->id);
    }
protected static function delete_all_user_data(context_user $usercontext) {
        global $DB;
        $userid = $usercontext->instanceid;

        // Delete all blog posts.
        $recordset = $DB->get_recordset_select('post', 'userid = :userid AND module IN (:blog, :blogext)', [
            'userid' => $userid, 'blog' => 'blog', 'blogext' => 'blog_external']);
        foreach ($recordset as $record) {
            $entry = new blog_entry(null, $record);
            $entry->delete();   // Takes care of files and associations.
        }
        $recordset->close();

        // Delete all external blogs, and their associated tags.
        $DB->delete_records('blog_external', ['userid' => $userid]);
        core_tag_tag::delete_instances('core', 'blog_external', $usercontext->id);
    }
protected static function delete_all_user_data ( context_user $ usercontext ) { global $ DB ; $ userid = $ usercontext -> instanceid ; // Delete all blog posts. $ recordset = $ DB -> get_recordset_select ( 'post' , 'userid = :userid AND module IN (:blog, :blogext)' , [ 'userid' => $ userid , 'blog' => 'blog' , 'blogext' => 'blog_external' ] ) ; foreach ( $ recordset as $ record ) { $ entry = new blog_entry ( null , $ record ) ; $ entry -> delete ( ) ; // Takes care of files and associations. } $ recordset -> close ( ) ; // Delete all external blogs, and their associated tags. $ DB -> delete_records ( 'blog_external' , [ 'userid' => $ userid ] ) ; core_tag_tag :: delete_instances ( 'core' , 'blog_external' , $ usercontext -> id ) ; }
Helper method to delete all user data.

@param context_user $usercontext The user context.
@return void
Helper method to delete all user data .