get_term_meta vs rwmb_meta
Support › MB Term Meta › get_term_meta vs rwmb_metaResolved
- This topic has 6 replies, 2 voices, and was last updated 2 years, 10 months ago by
brandonjp.
-
AuthorPosts
-
December 9, 2022 at 4:38 AM #39621
brandonjp
Participant// retrieve the user id from the related term $value = rwmb_meta( 'pm_related_user', ['object_type' => 'term'], $pm_term_id ); echo $value;// returns '' $meta = get_term_meta( $pm_term_id, 'pm_related_user', true ); echo $meta; // returns 8Based on the docs here: https://docs.metabox.io/extensions/mb-term-meta/#getting-field-value
I expected to both$value&$metato return the same.Any idea why
get_term_metaworks butrwmb_metadoes not?I'm using MB Term Meta * Version: 1.2.10
December 9, 2022 at 9:36 PM #39648Peter
ModeratorHello,
The value return from
rwmb_meta()could be an array and you cannot echo an array, you should use a for loop to iterate elements and echo it. Please use thevar_dump()function to know what the type of $value variable is.December 10, 2022 at 6:44 AM #39660brandonjp
Participanthmmm...
var_dump($value)from the above code is showingbool(false)December 11, 2022 at 10:33 PM #39688Peter
ModeratorHello,
Can you please share the code that creates the custom field on your site? And share some screenshots of the field value in the database?
December 12, 2022 at 9:38 AM #39701brandonjp
ParticipantHi Peter. Thanks for the reply. Truthfully this is not a big issue for me now, as I have it working using
get_term_meta()but I am still curious whyrwmb_meta()does not work.Below is the code used to create user select meta field on the taxonomy: https://cln.sh/QO9iJ6
array( 'id' => $prefix . 'pm_related_user', 'type' => 'user', 'name' => esc_html__('User Account', 'text-domain'), 'desc' => esc_html__('Select the User Account for this PM.', 'text-domain'), 'class' => 'add-add-new', 'query_args' => array( 'role__in' => 'c_____project_manager', ), 'field_type' => 'select_advanced', 'tab' => 'pm-tab', ),Here are some samples of the database where the user ID is correctly saving to the meta field
pm_related_user- https://cln.sh/4uPNJ3Thanks, Peter!
--BrandonDecember 13, 2022 at 10:14 PM #39761Peter
ModeratorHello,
I do not see the issue on my demo site when using the helper function
rwmb_meta()to get the term meta. Can you please update the plugin MB Term Meta to the latest version 1.2.10 and check this issue again? If you are using the older version (below 1.1), you can use the WordPress functionget_term_meta()only.December 13, 2022 at 10:19 PM #39762brandonjp
ParticipantI'm using MB Term Meta * Version: 1.2.10
Thanks for looking into it. But no problem, I’ll just stick with
get_term_meta -
AuthorPosts
- You must be logged in to reply to this topic.