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


Call a group datas from another group field

  • Hello,

    Please let me know if it’s posible to call a group data from another group field.
    so, i will try to explain.

    I have 2 group.
    1: Company
    field: company name, contact details, address
    2: Products
    field: name products, type products.

    Then on the post, i want to add a task work. when i add a task i want to asign to one company.
    But if i will add another task to the same company, i want to have one fied where i can select the company that i have already added.

    Please let mw know if you understend my issue ?
    Many regards.

  • Hi @d_alinus2004

    In this case, I suggest you use a custom post type for the company. That way, you can create the company first and then use the post object field to select the company you’ve created.

    Later, if you want to select the same company, then you can just select it from the post object field.

    You can also easily create the custom post type by using a third party plugin like Custom Post Type UI.

    I hope this helps 🙂

  • Hello,

    That’s means i wil have 2 custom type.
    1: Companie
    2: Task’s

    and will be dificult to complet the company profile for a new company on the same page.
    I will try to do it. I just install the type plugin and i will see how i can do it.

    Many thank’s for help.
    ps: on the PRO version it’s not posible ?

  • Hi @d_alinus2004

    I’m afraid the PRO version doesn’t have the feature you want. If you want, you can create dummy custom fields to provide the form for a new company profile, and then use the acf/save_post hook to save the new company profile to the company custom post type. But I’m afraid you need advanced code to do it.

    Hope this helps 🙂

  • Hello,

    I see this featured “dummy custom” and i belive it’s OK for my request.
    It’s dificult for me to code it on the source.

    If you help me how much cost it one work hour ?!

  • Hello,

    So, i have instal Wp types plugin.
    I have created 3 post type:
    1: Company
    2: Products
    3: Task.

    When i add a new task, i can call the comapany and the products from the post type.
    Now, the big problem it’s: If i want to add a new company on the same page, i must complet another fields.

    After i complet the fields it’s posible to migrate the field on the company type ?

    Many regards.

  • 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 🙂

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Call a group datas from another group field’ is closed to new replies.