Custom Fields
Re-Envisioned
Support MB Custom Table Saving user meta in custom table not working

This topic contains 3 replies, has 2 voices, and was last updated by  streamlinerr 2 months, 2 weeks ago.

  • Creator
    Topic
  • #13983
    Resolved
    streamlinerr
    Participant

    I’m trying to set up custom table for saving custom user meta, but I cannot get it to work. It works fine if I select post for custom fields group type, but not if I select user.

    Here’s the code I’m using for table creation:

    add_action( 'init', 'prefix_create_user_table' );
    function prefix_create_user_table() {
        if ( ! class_exists( 'MB_Custom_Table_API' ) ) {
            return;
        }
        MB_Custom_Table_API::create( 'prefix_users_data', array(
            'user_credits'   => 'BIGINT(10)',
        ));
    }

    For custom fields group definitions I’m using Metabox AIO and builder, with all extensions enabled.

    Where’s the catch?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #13984

    streamlinerr
    Participant

    custom fields code:

    add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
    function your_prefix_register_meta_boxes( $meta_boxes ) {
        $meta_boxes[] = array (
            'title' => 'User Data',
            'id' => 'user-data',
            'fields' => array(
                array (
                    'id' => 'user_credits',
                    'type' => 'number',
                    'name' => 'Credits',
                ),
            ),
            'table' => 'prefix_users_data',
            'type' => 'user',
            'storage_type' => 'custom_table',
        );
        return $meta_boxes;
    }
    #14001

    Anh Tran
    Keymaster

    Thanks a lot for your feedback. It’s a bug in the plugin and I’ve just fixed it in the version 1.1.8. Please update.

    #14005

    streamlinerr
    Participant

    It works now. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.