Skip to content
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

rest_value_cb not working #1284

Closed
MobinDev opened this issue Jul 23, 2019 · 4 comments
Closed

rest_value_cb not working #1284

MobinDev opened this issue Jul 23, 2019 · 4 comments

Comments

@MobinDev
Copy link

'rest_value_cb' not working on ".../wp-json/wp/v2/posts" and ".../wp-json/wp/v2/posts/<post_id>"
so i changed this line from :
$values[ $cmb_id ][ $field->id( true ) ] = $field->get_data();
to:
$values[ $cmb_id ][ $field->id( true ) ] = $field->get_rest_value();

@tw2113
Copy link
Contributor

tw2113 commented Jul 23, 2019

how are you specifying your properties and whatnot for your CMB2 instance? You shouldn't be needing to edit CMB2 core unless there's somehow a bug in place. Since this is a custom callback spot, you should be managing to provide your own callback and code in that callback.

@jtsternberg
Copy link
Member

Good call @MobinDev, I pushed an update.

@jtsternberg
Copy link
Member

@tw2113 basically, we use get_rest_value in the CMB2 REST endpoints, but we weren't using it in the default WP post endpoints when adding CMB2 data, so the update fixes that. get_rest_value simply calls get_data, and does some filters and such as well as allows a defined callback.

@tw2113
Copy link
Contributor

tw2113 commented Jul 23, 2019

I stand corrected, and am glad @jtsternberg is around for these things :)

Thanks everyone.

jtsternberg added a commit that referenced this issue Jul 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants