Home Forums Front-end Issues Call a group datas from another group field Reply To: Call a group datas from another group field

  • Hi @d_alinus2004

    Yes, you can do it by using the acf/save_post hook. In this hook, you can check if there’s data in the dummy form or not and then create a new post by using the wp_insert_post() function. It should be something like this:

    function my_acf_save_post( $post_id ) {
        // Only do this for "task" post type
        if( get_post_type($post_id) != 'task' ){
        // Get the posted value
        $company_title = get_field('dummy_company_title_name');
        $company_custom_field = get_field('dummy_company_custom_field_name');
        // Check if there's posted data
        if( !$company_title ){
        // Build the post data
        $the_post = array(
            'post_status'  => 'publish' ,
            'post_title'  => $company_title ,
            'post_type'  => 'company' ,
        // insert the post
        $company_post_id = wp_insert_post( $the_post ); 
        // Update the custom field
        // "field_1234567890abc" is the field key of the fields in the company post
        update_field('field_1234567890abc', $company_custom_field, $company_post_id);
        // Remove the saved custom field value in the task post
        // "field_abcdefghijk123" is the field key of "dummy_company_title_name"
        // and "field_asdfghjklzx123" is the field
        // key of the "dummy_company_title_name" field
        update_field('field_asdfghjklzx123', '', $post_id);
        update_field('field_abcdefghijk123', '', $post_id);
    // run after ACF saves the $_POST['acf'] data
    add_action('acf/save_post', 'my_acf_save_post', 20);

    If you don’t know how to code, I suggest you hire a developer to help you out with it, and I’d recommend looking for one on,, or

    Hope this helps 🙂