[wp-hackers] preventing new tags from being entered.

Helen Hou-Sandi helen.y.hou at gmail.com
Wed Sep 5 13:33:06 UTC 2012


On Wed, Sep 5, 2012 at 8:30 AM, Haluk Karamete <halukkaramete at gmail.com>wrote:

> Hi Helen
> Could you tell me the hooks/filters involved to make a change in the tag
> meta box?
>

This is a bit of code I have lying around for replacing taxonomy metaboxes
with a select-only interface using Chosen (
http://harvesthq.github.com/chosen/) as a multiselect helper:
https://gist.github.com/1573966

The relevant hook is basically just add_meta_boxes, or
add_meta_boxes_{$post_type}, so you can remove the metabox and then add
your own. Because you have many tags, I would probably suggest creating a
replacement that does autocomplete rather than loading all of the terms on
page load. If you name the field correctly ($tax_input[$tax_name]), saving
will take care of itself.


> And also wouldn't it be easier to just ignore the new tags at the time of
> update?
>

That's a pretty terrible user experience, especially given the default tag
metabox. "Here, I'll let you enter tags arbitrarily, but some of them might
not get used, and you won't know which ones!" In reality, you will want to
check capabilities on save in case data is manipulated, so you will want to
ignore new tags on update anyway. But just because it works behind the
scenes doesn't mean that you shouldn't also account for the actual user.
You still have to account for the actual tag/taxonomy admin screen as well.


More information about the wp-hackers mailing list