bsk_pdfm_after_document_insert
Description
Use this hook to perform actions after a document inserted into base. The hook is triggered when a document is inserted by the way of BSK PDF Pro --> Add New.
Usage
add_action( "bsk_pdfm_after_document_insert", "do_sepcial_action_when_new_document", 10, 5 );
Parameters
- $pdf_id integer. The id of the new inserted document.
- $pdf_categories array. The id of the categories that the document is assigned.
- $pdf_tags array. The id of the tags that the document is assigned.
- $file_url string. The URL of the file, empty string if no file uploaded.
- $extra_datas array. Extra data of the document, includes: title ( string), description ( string ), publish_date ( string ), expiry_date ( string ), status ( string ).
Example
Add new post and display the new document if its status is published.
add_filter( "bsk_pdfm_after_document_insert", "insert_post_and_display_the_document", 10, 5 );
function insert_post_and_display_the_document(
$pdf_id,
$pdf_categories,
$pdf_tags,
$file_url,
$extra_datas
) {
if ( $extra_datas['status'] != 'published' ) {
return;
}
$my_post = array(
'post_title' => $extra_datas['title'],
'post_content' => '[bsk-pdfm-pdfs-ul id="' . $pdf_id . '"]',
'post_status' => 'publish',
);
// Insert the post into the database
wp_insert_post( $my_post );
}
