Actions

feugt_uploadedfile_before

This action runs before a file is uploaded and inserted into the database.

Receives 1 Parameters:

  1. file_data- full info of the uploaded file.
    array(
    'name',
    'type',
    'tmp_name',
    'error',
    'size'
    );

    For example to get the uploaded file name we could use filedata[“name”].

feugt_uploadedfile_after_inserted

Runs before a file is uploaded but after it has already been inserted in the database

Receives 1 Parameters:

  1. $attachment_id or $feugt_id – the id of the attachment/post inserted, depends on the option where to upload( to attachments, or into the custom post type feugt(default).

feugt_uploadedfile_after

This action runs after a file has been uploaded and inserted into the database.

Receives 3 Parameters:

  1. $attachment_id or $feugt_id – the id of the attachment/post uploaded, depends on the option where to upload( to attachments, or into the custom post type feugt(default).
  2. $url – the url path for the already uploaded file
  3. $post_ids- In case you attached the uploaded file to a post

Example:

function test_after_upload($attachment_id,$url,$feugt_parent_post_ids){ //ATTACH FRONTEND UPLOADED FILE TO A SPECIFIC POST
$feugt_parent_post_ids = get_post_meta($attachment_id, 'feugt_parent_post_ids', true);
$feugt_parent_post_ids[] = 8 // POST ID TO ATTACH
update_post_meta($attachment_id, 'feugt_parent_post_ids', $feugt_parent_post_ids);
}
add_action('feugt_uploadedfile_after','test_after_upload');

Leave a Reply