• Resolved James Romanowski

    (@ploogodev)


    If someone could either help me out or point me in the right direction I would be most grateful.

    I am building a job board plugin where people can share a job post with other sites. I need to fill checkboxes with the site_id and then have it post to the site.

    Does anyone know how I can get these boxes pre-filled with the sitename and ID?

    https://www.ads-software.com/plugins/cmb2/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    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?

    Thread Starter James Romanowski

    (@ploogodev)

    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?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    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.

    Thread Starter James Romanowski

    (@ploogodev)

    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!

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    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.

    Thread Starter James Romanowski

    (@ploogodev)

    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.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Filling Multicheck Boxes with Multisite Site Names’ is closed to new replies.