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.
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.
This is the data in DB. It clearly shows post ID = 2.
The custom table is created via the Web GUI, there is no code. screenshot below:
This is the creation of fields:
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;
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.
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;
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.
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.
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.
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.
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);
<br />upload pic<br />
all metabox plugins and addons have been updated to the latest version and the problem still persists.