Hi
I'm tried like a madness to figure out how to display relationship fields.
I have tried any compination from the documentation, and i'm just so lost.
I have created a term for products: venues
I have created a relationship with code:
Its to be able to add the terms in the users metadata.
function your_prefix_function_name() {
MB_Relationships_API::register( [
'id' => 'venue-to-user',
'from' => [
'object_type' => 'term',
'taxonomy' => 'venues',
'meta_box' => [
'title' => 'From title',
],
'field' => [
'name' => 'from label',
'max_clone' => '1',
],
],
'to' => [
'object_type' => 'user',
'post_type' => 'post',
'taxonomy' => 'category',
'meta_box' => [
'title' => 'To title',
],
'field' => [
'name' => 'To label',
'max_clone' => '1',
],
],
] );
}
I try to output it like the documentation says:
$terms = get_terms( [
'taxonomy' => 'venues',
'hide_empty' => false,
'relationship' => [
'id' => 'venue-to-user',
'to' => 1, // <--user ID
],
] );
foreach ( $terms as $term ) {
print_r($term);
}
But i'm getting this output:
Array ( [invalid_taxonomy] => Array ( [0] => Invalid taxonomy. ) ) Array ( )
I want to have a cpt or taxonomy that can be related to a user and then output the data on the checkout page.
Adding it to the checkout page is not the problem, but output the relationship field is.