-
Notifications
You must be signed in to change notification settings - Fork 572
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 multicheck values and $cmb->get_sanitized_values( $_POST ); #538
Comments
The taxonomy fields are not intended to provide an arbitrary list of terms to pick from, but are intended to be a replacement for the default taxonomy metaboxes. I.e. they are meant to set the taxonomy terms on an object. Any other use of these types will be hacky and/or buggy. I suggest looking at building a custom field type for this: https://github.com/WebDevStudios/CMB2/wiki/Tips-&-Tricks#a-dropdown-for-taxonomy-terms-which-does-not-set-the-term-on-the-post |
I am using the taxonomy_multicheck fields for my custom taxonomies to set the taxonomy terms on my custom post. I am trying to accomplish a frontend implementation of what the default taxonomy metaboxes do on the backend, but when the values are sanitized the taxonomy terms that were selected using the field are gone. |
are you using the front-end form to save an existing post, or create new? If saving an existing post, there's no reason you should be using get_sanitized_values. You should be using something similar to this: https://github.com/WebDevStudios/CMB2-Snippet-Library/blob/master/front-end/cmb2-metabox-shortcode.php |
I am creating a new resource. For testing I am dumping the $_POST and then dumping the $_POST after it has been sanitized. |
Again, the taxonomy fields are not intended to be used the way you are using them. I suggest: https://github.com/WebDevStudios/CMB2/wiki/Tips-&-Tricks#a-dropdown-for-taxonomy-terms-which-does-not-set-the-term-on-the-post |
I am having trouble understanding how the taxonomy_multicheck field is supposed to be used, if it isn't for setting the taxonomy terms for my post. |
Sorry Justin, Lets break it down like this B. Should I expect taxonomy_multicheck values to survive get_sanitized_values()? C. I am currently assuming that as I process the frontend form I have to implement code that will save the values for my taxonomy_multicheck fields, CMB2 is not going to save values for me automatically, which is why I was thinking it should go through the sanitization and then I will save the terms for the post. |
@jondcampbell Is this still presenting an issue for you? Perhaps it has since been resolved by the fields working as expected finally, or by some sort of hotfix/change in what you're using for the frontend? Justin from the looks of things, he was using the field types properly, wanting to set terms for the post objects, as opposed to saving term information to post meta. The data wasn't getting past the sanitization functions though. |
Hey @tw2113 , Ended up switching to ACF for this project so this Issue doesn't really matter to me anymore. |
No worries, thanks Jon. Leaving open for further investigation |
As a follow-up, since Jon reminded me of this thread today :), basically, the tax fields use the same field name structure that WP admin expects for the built-in tax-term UI, so WP saves them for us for free (CMB2 doesn't handle the term-setting/saving bit). If you use those tax fields outside of the post edit screen, WP won’t do the work for you, so you're on your own. You’re right in that it should likely have a fallback saving mechanism in scenarios where the fields are not being used in the post-edit screen (or at least document this limitation in the wiki until it can be addressed). |
I have a frontend form.
When the form submits my text, wysiwyg, and taxonomy_multicheck fields are all in the $_POST.
When I look at the dump of $cmb->get_sanitized_values( $_POST ) all my taxonomy_multicheck values are gone, so I can't process them and save the submission. My text and wysiwyg fields survive the get_sanitized_values()
The text was updated successfully, but these errors were encountered: