Custom Fields
Re-Envisioned
Support MB Custom Table How to get user meta from custom table?

This topic contains 4 replies, has 2 voices, and was last updated by  todd m young 11 months, 2 weeks ago.

  • Creator
    Topic
  • #11511
    Resolved
    todd m young
    Participant

    I cant seem to get my user meta out of the custom table. Tried this:
    $value = rwmb_meta( 'address', array( 'object_type' => 'user', 'storage_type' => 'custom_table', 'table' => "metabox_users" ), 1 );
    But get nothing. I have checked the table, and the data is stored in there, as expected.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #11512

    Anh Tran
    Keymaster

    Hi Todd,

    I’ve just checked and found a bug in the core plugin. Would you mind download the latest version on Github?

    Thanks for the bug report!

    #11517

    todd m young
    Participant

    Yes! That worked, thank you 🙂

    Is there a function to retrieve all metabox fields, from a custom table? (in this case for a User, but I was wondering about posts as well)

    #11532

    Anh Tran
    Keymaster

    Yes, please use:

    MB_Custom_Table_Cache::get( $object_id, $table_name )

    It returns an array of key => value.

    #11539

    todd m young
    Participant

    Excellent, thank you.
    Some users may be interested in my little function:

    function mb_customtable_getRow($object_id, $table_name){
        $ra =  MB_Custom_Table_Cache::get( $object_id, $table_name );   
        foreach($ra as $k=>$v){
            $newra[$k] = maybe_unserialize( $v );//this is a wp func.
        }
        return $newra;
    }
Viewing 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.