Support Forum
Support › Meta Box Group › Repeatable group data not in REST responseResolved
Hi,
I'm trying to use meta-box to create an interface for data that will be returned by the REST API. I have the MB Rest API and Meta Box Group plugins installed.
I have the following definition for data fields:
add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
function your_prefix_function_name( $meta_boxes ) {
$prefix = '';
$meta_boxes[] = [
'title' => __( 'Nav page', 'your-text-domain' ),
'id' => 'nav-page',
'post_types' => ['page'],
'fields' => [
[
'name' => __( 'Group', 'your-text-domain' ),
'id' => $prefix . 'group_mja12hpcr0h',
'type' => 'group',
'clone' => true,
'fields' => [
[
'name' => __( 'Name', 'your-text-domain' ),
'id' => $prefix . 'name',
'type' => 'text',
],
[
'name' => __( 'Relative url', 'your-text-domain' ),
'id' => $prefix . 'url_b4fovvhcvnb',
'type' => 'text',
],
[
'name' => __( 'Icon', 'your-text-domain' ),
'id' => $prefix . 'icon_fa',
'type' => 'text',
],
],
],
],
];
return $meta_boxes;
}
After adding data to a couple of these groups, in the REST response I only see this:
"meta_box": {
"group_mja12hpcr0h": []
},
How do I get this to work?
Hi,
I've tested this extension again on my local site and see it works as well, screenshots
https://share.getcloudapp.com/RBuyK1qw
https://share.getcloudapp.com/6quEO72z
Can you please re-check the field group value and page ID?
http://yoursite.com/wp-json/wp/v2/pages/1234
Thanks Long,
I missed out an important parameter, sorry. I'm wanting to do this with a Private page that can only be accessed by an authenticated user.
It works on a Public page for me also, as you have pointed out.
Hi,
You can follow this topic to access private posts via WP REST API https://stackoverflow.com/questions/30541838/how-to-retrieve-private-posts-from-wordpress-using-json-rest-api
The issue not how to access private posts. The issue is that the empty group_* result I posted initially only occurs if I set the page to private and access it as described in that stackoverflow answer.
This an example command I use for testing where it fails as described above.
curl -k --user user:passwd "https://myapp.local/wp-json/wp/v2/pages?_embed"
As already mentioned if the page is set to public then it works as expected.
Sorry, I copied the wrong thing, in the above post, the example command is actually this
curl -k --user user:passwd "https://myapp.local/wp-json/wp/v2/pages?_embed&status=private"
Solved. It started working after I restarted the server.