Support

Account

Home Forums General Issues ACF Form : Create new on different subsite [Multisite]

Helping

ACF Form : Create new on different subsite [Multisite]

  • Following this documentation, I created a frontend form that, on submission, creates a post and sends an email notification.

    The thing is, while the field group is located on the main subsite (ID:1) of a multisite network, I actually want to display the form on several subsites.

    I managed to display the form with no problem with switch_to_blog();

    switch_to_blog(1);	
    $today = date("Y-m-d-H-i-s");
    
    $args = array(
    'post_id' => 'new_post',
    'new_post' => array(
    'post_type' => 'enquiry', 
    'post_status' => 'publish', 
    'post_title' => $today  
    ),
    'field_groups' => array(3496),
    );
    acf_form($args);
    
    restore_current_blog();
    add_action('acf/save_post', 'create_post_from_form_v2');
    function create_post_from_form_v2($post_id) {
    ...
    }

    However, since the field group (nor the CPT) doesn’t exist on the secondary subsites, the post creation and email notification do not work.

    Is there any way to create the new post on a specific subsite?

    Or, is it possible to get the values of the submitted form without actually creating a post? I would then use insert_new_post() to create the post and send the email.

    I know that an alternative could be to create the CPT on the secondary subsites and synchronize the field group on all the subsites so as the new post is created on the current subsite, but I would like to avoid that.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.