wp_handle_upload: get custom checkbox value from media uploader

I found a snippet to add a checkbox to media uploader using action post-upload-ui

Snippet found here

Read More
/**
 * Add checkbox to set autocreate on upload
 */
function fifteenccgal_autocreate_post_on_image_upload_form_tweaks()
{
    ?>
    <label style="display: inline-block; padding: 5px 8px; border: 3px solid lightgrey; border-radius: 1em">
        <input  type="checkbox" 
                id="fifcc_autocreate" 
                name="fifcc_autocreate" 
                value="1" 
                <?php echo ((FIFTEENCCGAL_AUTOCREATE_DEFAULT_STATE == 1) ? 'checked="checked"' : '')?>" />
         Auto-create a Photo Post for each uploaded image?
    </label><br/><br/>
    <script type="text/javascript">
        jQuery(function ($) {
            $('#fifcc_autocreate').change(function (e) {
                uploader.settings.multipart_params.fifcc_autocreate = ($('#fifcc_autocreate:checked').val() ? 1 : 0);
            })
        });
    </script>
    <?php
}
add_action('post-upload-ui', 'fifteenccgal_autocreate_post_on_image_upload_form_tweaks');

////
// You might also wish to set a default value on load. WordPress provides a suitable hook…
////

/**
 * Initialise the value to reflect the checkbox default
 */
function fifteenccgal_autocreate_post_on_image_upload_post_params_init($params)
{
    $params['fifcc_autocreate'] = FIFTEENCCGAL_AUTOCREATE_DEFAULT_STATE;
    return $params;
}
add_filter('upload_post_params', 'fifteenccgal_autocreate_post_on_image_upload_post_params_init');

My question is:
how can I handle the user choice on upload?

I tried something like that

add_filter('wp_handle_upload', 'my_wp_post_upload');

function my_wp_post_upload($fileinfo){

   if(!empty($_POST)) {
    ob_start();
    var_dump($_REQUEST);
    var_dump($_FILES);
    $datapost = ob_get_clean();
    $fpp = fopen("wp_handle_upload.txt", "a");
    fwrite($fpp, $datapost);
    fclose($fpp);

   }
}

To understand what wp_handle_upload is passing but I get only

array(4) {
  ["name"]=>
  string(10) "band_1.jpg"
  ["action"]=>
  string(17) "upload-attachment"
  ["_wpnonce"]=>
  string(10) "f3c98e2267"
  ["post_id"]=>
  string(3) "177"
}
array(1) {
  ["async-upload"]=>
  &array(5) {
    ["name"]=>
    string(10) "band_1.jpg"
    ["type"]=>
    string(10) "image/jpeg"
    ["tmp_name"]=>
    string(14) "/tmp/phpn3I1HG"
    ["error"]=>
    int(0)
    ["size"]=>
    int(34789)
  }
}

No way to get the checkbox choice here?

Thanks

Related posts

Leave a Reply