public static function delete_item_tags(\context $context, $component, $itemtype,
            $itemid = null, $userid = null) {
        global $DB;
        $params = ['contextid' => $context->id, 'component' => $component, 'itemtype' => $itemtype];
        if ($itemid) {
            $params['itemid'] = $itemid;
        }
        if ($userid) {
            $params['tiuserid'] = $userid;
        }
        $DB->delete_records('tag_instance', $params);
    }
public static function delete_item_tags(\context $context, $component, $itemtype,
            $itemid = null, $userid = null) {
        global $DB;
        $params = ['contextid' => $context->id, 'component' => $component, 'itemtype' => $itemtype];
        if ($itemid) {
            $params['itemid'] = $itemid;
        }
        if ($userid) {
            $params['tiuserid'] = $userid;
        }
        $DB->delete_records('tag_instance', $params);
    }
public static function delete_item_tags ( \ context $ context , $ component , $ itemtype , $ itemid = null , $ userid = null ) { global $ DB ; $ params = [ 'contextid' => $ context -> id , 'component' => $ component , 'itemtype' => $ itemtype ] ; if ( $ itemid ) { $ params [ 'itemid' ] = $ itemid ; } if ( $ userid ) { $ params [ 'tiuserid' ] = $ userid ; } $ DB -> delete_records ( 'tag_instance' , $ params ) ; }
Deletes all tag instances for given context, component, itemtype, itemid

In most situations you will want to specify $userid as null. Per-user tag instances
are possible in Tags API, however there are no components or standard plugins that actually use them.

@param   \context    $context The context to export for
@param   string      $component Tagarea component
@param   string      $itemtype Tagarea item type
@param   int         $itemid The itemid within that component and itemtype (optional)
@param   int         $userid Only delete tag instances made by this user, per-user tags must be enabled for the tagarea
Deletes all tag instances for given context component itemtype itemid