I’m a little confused. Would the site name/ID be something that is populated when the user posts the job to the site with the job board?
Sorry about the confusion. When someone fills out a job post in the admin there will be CMB2 Multi checkboxes that have a site name listed for each checkbox. Those sites will be from the multisite network. When someone checks one of those boxes that job will post to the checked sites’ archive page. Does this help?
Yes, that does help clear up the confusion. Thanks.
Is this going to be in a post type editor screen? Or is it going to be some custom form that won’t immediately create a post within the site it’s housed in?
Either way, there is going to be need to intercept the form data and create a post in the specified network site. For that, you’re going to be needing to use things like switch_to_blog/restore_current_blog as well as wp_insert_post() to put it into the correct area. That step isn’t going to be specific to CMB2.
A part that would be more specific to CMB2 would be constructing a list of the sites available in the network, so that you can confirm which one was selected and use the switch_to_blog function to point the code to that site temporarily. I would recommend using both the site ID and site name for this, with the checkboxes.
Hopefully I’ve given some good ideas to implement or at least research, but if you’re still confused on any part, let me know and I’ll do my best to explain some more or provide some examples.
It is in a post type editor screen. So it will post on the site it’s on as well.
You’re suggestions are very helpful. Especially in regards to wp_insert_post(). You’ve given me some very helpful ideas. Thanks so much Michael!
Since you’re doing it via a post type editor screen, I’d do an action hook on the ‘publish_$posttypeslug’ hook so that you can intercept it all and do what you must to post to the other site in the network.
Let us know if you need anything else.
Oh, that’s valuable as well. I will take a crack at it and if I need anything more I will get in touch. Thanks again for replying so quickly.