-
Notifications
You must be signed in to change notification settings - Fork 571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Taxonomy picker on User edit saves mysteriously #1489
Comments
The You'd want to make use of https://github.com/CMB2/CMB2/wiki/Field-Types#multicheck-and-multicheck_inline and https://github.com/CMB2/CMB2/wiki/Field-Parameters#options_cb to fetch the terms in the taxonomy, and return your array with that. |
Thanks for the pointer. $cmb->add_field(array(
'name' => 'Company',
'id' => 'company',
'type' => 'multicheck',
'options_cb' => 'cmb_company_terms',
'select_all_button' => false,
)); function cmb_company_terms($field)
{
// Get all "company" terms into an associative array
// Get all terms of the 'company' taxonomy
$terms = get_terms(array(
'taxonomy' => 'company',
'hide_empty' => false,
'fields' => 'id=>name',
));
return $terms;
} What do you think? In ACF, I think it just figures out where to put the data, wherever I might put a taxonomy selector, so I think that's why I hope this would happen here. -- By the way, unlike for user, I seem to have had some success in setting a ++ Presumably, |
Majority of the fields all have the items listed at https://github.com/CMB2/CMB2/wiki/Field-Parameters as available. So, yes, checkbox should as well. Regarding flags, kind of a case of it's working in a way that you could work with, why not. I would need to trace my way through the core code to come up with any sort of answer of how/why it works. |
Describe the bug
When a
taxonomy_multicheck_hierarchical
is added to'object_types' => array('user')
, the value may be saved... somewhere... but not apparently inwp_usermeta
as expected.I cannot find any trace of the value getting saved in the database, though possibly it is settling as an wp_options transient, not sure.
When the value is unchecked and the User is re-saved, the value stays checked on reload.
Overall very odd behaviour.
If User cannot simply take a taxonomy field, what is the correct procedure for both saving and retrieving values?
Steps to reproduce
Register a metabox, add a taxonomy field to user.
CMB2 Field Registration Code:
Your Environment
WordPress 6.2, MAMP, macOS, PHP 7.4.33.
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: