Hello,
Thanks for the feedback!
If you’re using a Custom Action, you can access your File field value using get_field('my_file')
within the acfe/form/submit_my-action
custom action submit hook (see documentation).
Usage example:
add_action('acfe/form/submit_my-action', 'my_custom_action_submit', 10, 2);
function my_custom_action_submit($form, $action){
// get file value
$file = get_field('file');
// log file
acf_log($file);
/*
* Array(
* [ID] => 350
* [id] => 350
* [title] => 200.gif
* [filename] => 200.gif
* [filesize] => 834989
* ...
* )
*/
}
Here is a Field Group + Form you can use which will work with the code example above.
Field Group:
add_action( 'acf/init', function(){
acf_add_local_field_group( array(
'key' => 'group_61a638bfcec10',
'title' => 'My Form',
'fields' => array(
array(
'key' => 'field_664bfb05e1c85',
'label' => 'File',
'name' => 'file',
'aria-label' => '',
'type' => 'file',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'hide_field' => '',
'hide_label' => '',
'hide_instructions' => '',
'hide_required' => '',
'uploader' => '',
'return_format' => 'array',
'upload_folder' => '',
'multiple' => 0,
'max' => '',
'acfe_settings' => '',
'acfe_validate' => '',
'min_size' => '',
'max_size' => '',
'mime_types' => '',
'instruction_placement' => '',
'acfe_permissions' => '',
'library' => 'all',
'preview_style' => 'default',
'placeholder' => 'Select',
'button_label' => 'Add File',
'stylised_button' => 0,
'file_count' => 0,
'min' => '',
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'post',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'left',
'instruction_placement' => 'field',
'hide_on_screen' => '',
'active' => true,
'description' => '',
'show_in_rest' => 0,
));
});
ACFE Form:
add_action( 'acfe/init', function(){
acfe_register_form(array(
'name' => 'my-form',
'title' => 'My Form',
'field_groups' => array(
'group_61a638bfcec10',
),
'actions' => array(
array(
'action' => 'custom',
'name' => 'my-action',
),
),
));
});
You can simply display it with [acfe_form name="my-form"]
shortcode, or acfe_form('my-form')
PHP code.
Hope it helps!
Have a nice day!
Regards.