1. Home
  2. Knowledge Base
  3. Custom Development
  4. Download Repository – retrieve_single
  1. Home
  2. Knowledge Base
  3. Download Repository
  4. Download Repository – retrieve_single

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.


public function retrieve_single( $id );


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


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?

Related Articles

Start Protecting your WordPress Downloads

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