This filter is called after the category is detected in the subject line. You could use this filter to create a missing category or force it to be one of a list of approved categories. Note this filter will be called multiple times if there are multiple categories in the subject line.
You should return a string that is a valid category or taxonomy term. If the returned value is not a valid category or taxonomy term then the unknown category will remain in the subject line.
Parameters:
- $category_name – the category extracted from the subject line. Note this could be a category ID. The delimiters are not included e.g. for the subject line “[mycategory] subject line” this parameter would be “mycategory”
- $match_short_category – a boolean indicating if Postie will try to look up the category using “starts with” logic. Controlled by the “Match short category” setting.
- $default – the default category as defined by the “Default category” setting or the results of the postie_category_default filter.
add_filter('postie_category', 'my_postie_category', 10, 3); function my_postie_category($category_name, $match_short_category, $default) { return ''; //don't allow user to set category }