Custom Fields
Re-Envisioned
Support MB User Meta "mb_user_meta & mb_rest_api" has problem Reply To: "mb_user_meta & mb_rest_api" has problem

#13796

Jiro
Participant

Thanks for your effort, but I found something strange.
As your kindly support, that was not working with me.

Instead of that in MB-REST-API…

I found ‘$field’ has wrong value. in 198 line of class-mb-rest-api.php

foreach ( $data as $field_id => $value ) {
            $field = rwmb_get_registry( 'field' )->get( $field_id, 'user' );
            $this->update_value( $field, $value, $object->ID );
        }

and I change the code like below and everything works fine.

foreach ( $data as $field_id => $value ) {
            $field = rwmb_get_registry( 'field' )->get( $field_id, 'user', 'user' );
            $this->update_value( $field, $value, $object->ID );
        }

The code which I used for MB user meta is below.

<?php
add_filter( 'rwmb_meta_boxes', 'prefix_register_meta_boxes' );

function prefix_register_meta_boxes( $meta_boxes ) {
    $meta_boxes[] = array(
        'title' => 'Personal Information',
        'type' => 'user', // Specifically for user

        'fields' => array(
            array(
                'name'  => 'test mb for user',
                'desc'  => '',
                'id'    => 'test5',
                'type'  => 'text',
            ),
        )
    );
    return $meta_boxes;
}

and when I print var_dump(rwmb_get_registry( ‘field’ )).
it printed out as like below. as you can see there is “user” under the “user”.
So strange, isn’t it?

I never modify any Metabox source code in before includes (mb-rest-api, mb-user-meta,…)