I’ve set up my user profiles to allow custom taxonomies following this tutorial.
Ideally, I’d like to use the default Tag meta box from the Post screen, so users can easily add new terms and find commonly used ones. I’m currently using a checkbox list, but this could get very long as we’ll have a number of taxonomies. Could I somehow use the post_tags_meta_box()
? I’ve looked into add_meta_box()
but that doesn’t work on 'user'
.
This code works for me. It uses ‘locations’ custom taxonomy and ‘suggest’ javascript. You need to extend it to support multiple term selection.
Add custom field to user-edit screen and store metadata when user/admin updates profile
Enqueue suggest javascript for user-edit screen only (assuming you use this in custom theme)
usermeta.js
Unfortunately, I’d say the answer is no.
You could hijack (copy + paste) the code from
post_categories_meta_box()
and try to adapt it to the user, however you’d spend more time trying to reconnect all the pieces. I’m pretty sure the post meta boxes use ajax to save and add new terms, so you’d have to hijack some javascript and modify that as well.I think your best bet is to continue down the path you’re on. You can add an
overflow:scroll;
css property to your checkbox container so that it doesn’t get too long.I reversed engineered the post meta boxes for the front end a few months ago, and it wasn’t too hard. I wouldn’t suggest trying to reuse the markup and php functions from the core though. Instead, use them as a guide if you get stuck.
Brief answer to only sketch out what needs to be done:
wp_enqueue_script( 'posts' );
(or however that script handle was called).