Support

Account

Home Forums Backend Issues (wp-admin) Add subfields with php to the current field type “group” Reply To: Add subfields with php to the current field type “group”

  • I’ve figured out that my problem is to get current post_id when add_filter(‘acf/init’, ‘acf_load_table_grid’); call.
    I’m trying to create fields from the current field data of the current post. But it doesn’t save field data. I’ve checked it. So reason is that in this filter impossible to get post_id ($_GET[‘post’]) when fields are saving. Do you have any ideas how to correctly get post_id? Because when fields are saving script “knows” what post in the process, evidently.
    I’m sure it’s possible.

    Let’s imaging that you want to create such function:

    
    add_filter('acf/init', 'acf_load_table_grid');
    function acf_load_table_grid( ) {
                              acf_add_local_field(array(
    				'key' => 'field_mypost'.get_the_ID(),
    				'type' => 'text',
    				'name' => 'field_myfield_myfield'.get_the_ID(),
    				'parent' => 'some_parent_field',
    			));
    }
    

    get_the_ID(), $_GET[‘post’] – doesn’t allow to save data in field

    So any suggestions?
    Thanks for your attention! Support rejected me in any help even I have PRO subscription.