I'm trying to accomplish something that shouldn't be too difficult. However, I cannot get it right. The situation is as followed: I have a multisite with 2 subsites. All the 3 sites have their own custom post types.
I am trying to achieve the following: when a custom post type post is create on site ID = 3 using an ACF Frontend Form, this automatically creates another custom post type post on site with ID = 2.
Using the code below I am able to cross-post the posts from site A to site B. However now I only need to send the title through the Front-end form. The updated code can be found below:
add_action('publish_holiday', 'add_surf_holiday', 10, 2);
function add_surf_holiday($post) {
switch_to_blog(2);
/* the rest of the function code */
$labels = array(
'post_title' => $_POST['acf']['name_surf_accommodation'],
'post_status' => 'publish',
'post_type' => 'surf-holidays'
);
wp_insert_post( $labels );
restore_current_blog();
}
Does any of you have an idea how to solve this issue?
If anything is unclear, please let me know.
Hope to hear from you soon!
Cheers,
Hans
question from:
https://stackoverflow.com/questions/65922067/send-acf-frontend-form-title-through-using-publish-post-in-a-multisite 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…