Hey guys,
I hope you guys can hel me out with the following: I have a WP multisite installation, with some custom post types. The goal is that when someone adds a ‘custom post a post ‘ (=’holiday’)is created on site with ID = 3 using an ACF frontend form, that a ‘custom post b post’ (=’surf-holiday’) on site with ID = 2 is created. I am using the function in a must-use plugin:
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();
}
This function works, however it does not send the Post title through to the newly created post. It does work perfectly when creating a post in the admin dashboard, but I need to make it work with a front-end form as well.
Does anyone has an idea how to solve this issue? Please let me know!
Cheers,
Hans