Download Repository – retrieve_single

Please note: Functionality described on this page requires Download Monitor version 4.0 or above.

Downloads in Download Monitor can be fetched via the Download Repository. Retrieve_single is a method of Download Monitor’s download repository service. The method returns a single DLM_Download object with given ID. Retrieve_single throws an Exception if no download with given ID is found.

Signature

public function retrieve_single( $id );

Parameters

ParameterTypeDefaultDescription
$idintn/aID of the download that needs to be fetched.

Examples

Retrieve Download with ID 4

This snippet retrieves download with ID 4. Notice that the retrieve_single call is wrapped in a try-catch block. This is because the retrieve_single method throws an exception if no Download with given ID is found.

try {
	$download = download_monitor()->service( 'download_repository' )->retrieve_single( 4 );
} catch ( Exception $exception ) {
	// no download with ID 4 found
}
Was this article helpful?
Start Protecting your WordPress Downloads

Protect and track downloads on WordPress... What are you waiting for?