rwmb_meta not working for Custom Table

Support MB Custom Table rwmb_meta not working for Custom Table

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #29621
    ABAB
    Participant

    I have created a custom table, the values are stored properly and correctly in the DB. But I cannot retrieve the values either using PHP code or Shortcode.

    To clarify, values are saved in the DB as expected. But I cannot use 'rwmb_meta' to get the data.

    The tables are created automatically via web UI (with no prefix).

    I tried both but nothing works:

    $value = rwmb_meta( 'primary_mobile', ['storage_type' => 'custom_table', 'table' => 'ab_subscriber_info'], 2 );
    echo $value;

    [rwmb_meta id="primary_mobile" object_id="2" storage_type="custom_table" table="ab_subscriber_info"]

    Appreciate any help.

    #29629
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Please make sure that 2 is the post ID that you save the field value. And please share the code that creates the custom table and fields. I will try to run the code on my end to investigate the issue.

    #29631
    ABAB
    Participant

    This is the data in DB. It clearly shows post ID = 2.

    db

    The custom table is created via the Web GUI, there is no code. screenshot below:

    web

    This is the creation of fields:

    field

    #29632
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The table name is wp_subscriber_info, can you please recheck it?

    $value = rwmb_meta( 'primary_mobile', ['storage_type' => 'custom_table', 'table' => 'wp_subscriber_info'], 2 );
    echo $value;
    #29633
    ABAB
    Participant

    Yes I rechecked. Initial prefix was 'ab_' then I used wordpress' default prefix 'wp_' but those still dont work. The typos was because I was experimenting with different settings. Still doesnt work. Appreciate your further advise.

    #29635
    ABAB
    Participant

    Just to confirm, I rechecked my code and shortcode as follows and still doesn't work.

    [rwmb_meta id="primary_mobile" storage_type="custom_table" table="wp_subscriber_info" object_id=2]

    $primary_mobile = rwmb_meta( 'primary_mobile', ['storage_type' => 'custom_table', 'table' => 'wp_subscriber_info'], 2 );
    echo $primary_mobile;
    #29636
    ABAB
    Participant

    So I tried creating a new custom table for Post type. It still doesn't work when trying to get value from custom table, but saving to table is working perfectly fine. Please see all configuration below. I think there's a bug somewhere.

    #29637
    Long NguyenLong Nguyen
    Moderator

    Hi,

    For the case above, user meta. You need to add the attribute object_type to the second argument. Get more details on the documentation https://docs.metabox.io/extensions/mb-user-meta/#getting-field-value

    $primary_mobile = rwmb_meta( 'primary_mobile', ['storage_type' => 'custom_table', 'table' => 'wp_subscriber_info', 'object_type' => 'user'], 2 );
    echo $primary_mobile;

    Please try to run the code and let me know how it goes.

    #29638
    ABAB
    Participant

    Hi, just tried adding in object_type in the 2nd argument and still doesn’t work. Even my experiment with a normal Post type doesn’t work as above.

    #29644
    Long NguyenLong Nguyen
    Moderator

    Hi,

    It's so weird. Please try to follow the Debugging Information step here https://support.metabox.io/topic/how-to-create-a-new-topic/.

    If there is no error message and the helper function still does not work, please share your site credentials via this contact form https://metabox.io/contact/. I will help you to check the issue.

    #33286
    Nicholas CoxNicholas Cox
    Participant

    Hi

    this is also not working for me. Returns empty value.

    $value = rwmb_meta( 'city', ['storage_type' => 'custom_table', 'table' => 'wp_dc_users', 'object_type' => 'user'], 3 );
    var_dump($value);

    Capture<br />upload pic<br />

    #33287
    Nicholas CoxNicholas Cox
    Participant

    all metabox plugins and addons have been updated to the latest version and the problem still persists.

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.