Version Repository – retrieve_single

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

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


public function retrieve_single( $id ) {}


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


Retrieve Version with ID 91

This snippet retrieves version with ID 91. 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 Version with given ID is found.

try {
// retrieve version with ID 91
/** @var DLM_Download_Version $version **/
$version = download_monitor()->service( 'version_repository' )->retrieve_single( 91 );
} catch ( Exception $exception ) {
// version with ID 91 not found
Was this article helpful?
Start Protecting your WordPress Downloads

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