terms – How to get the $meta_type given the $object_id

Question

I’m trying to copy meta data from a term to an object when that term is assigned to the object by way of wp_set_object_terms(). When I hook into set_object_terms, I am able to obtain the desired $meta_key and $meta_value (as well as the desired $object_id, which is passed via the hook). The problem lies when I go to copy the term meta to the object. This can only be done by way of update_metadata($meta_type, $object_id, $meta_key, $meta_value) because I do not know the $meta_type (specifically, I cannot use update_post_meta(), update_comment_meta(), update_user_meta(), etc).

Given the $object_id (and a WP_Term object), how does one go about determining the $meta_type to be passed to update_metadata()? Specifically, I am looking to calculate a string value equal to post, comment, term, user, or any other string that identifies an object type with an associated meta table.

0
Mort 1305 4 months 2022-04-05T10:42:12-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse