- This topic has 3 replies, 2 voices, and was last updated 1 year, 2 months ago by .
-
Topic
-
I’m having trouble setting a default value & hoping you can guide me:
- I have a Custom Post Type called “Job” with a taxonomy select field called “job_manager”
- I have a Custom Taxonomy called “Manager” with a user select field called “wp_user”
When creating a new Job, I want to select the default value for “job_manager” to be the currently logged in user, but so far I’m having trouble understanding how the terms are attached and how to set the default term.
Basically, what value do I want from the Manager term? And how do I assign it as default
I’ve written code based on this guide: https://docs.metabox.io/edit-meta-boxes/ to modify the meta box.
add_filter('rwmb_meta_boxes', 'select_jobmanager_edit_meta_boxes', 20); function select_jobmanager_edit_meta_boxes($meta_boxes) { // Loop through all metaboxes foreach ($meta_boxes as $k => $mb) { if (isset($mb['id']) && 'job-personnel' == $mb['id']) { // Loop through all fields foreach ($mb['fields'] as $j => $field) { // Find the manager taxonomy field if ('job_manager' == $field['id']) { // Here I'll get_current_user then find the "manager" term // using get_terms/'meta_query' with matching the "wp_user" // But what value do I need from the "manager" term & // and what property do I set on the field $meta_boxes[$k][$j]['std'] = ['44']; } } } } // Return edited meta boxes return $meta_boxes; }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.