Description:

This function returns the values of the package info with the specified key from the specified package.
Usage:

<?php get_package_data($id, $key); ?>

 

Parameters:

$id: The ID of a package

$key: A string containing the name of the package info you want.

Valid Keys:

  • access
  • download_count
  • view_count
  • version
  • link_label
  • quota
  • download_limit_per_user
  • package_size
  • package_size_b
  • individual_file_download
  • template
  • page_template
  • password_lock
  • password
  • password_usage_limit
  • email_lock
  • tweet_lock
  • facebook_lock
  • googleplus_lock
  • files
  • fileinfo
  • package_dir
  • publish_date
  • expire_date
  • icon
  • base_price
  • sales_price
  • variation

 

Example:

To get the download_count for a package with ID 2:

<?php
$download_count = get_package_data(2, 'download_count');
echo $download_count;
?>

 



Discussion

  • brunzino

    I’m trying to get a package’s full path (e.g. /var/www/wordpress/wp-content/uploads/my_file.pdf) for a given package.

    $path = get_package_data($id, 'package_dir');     // returns nothing. 
    $info = get_package_data($id, 'fileinfo');     // also returns nothing. 
    $count = get_package_data($id, 'download_count');     // returns an integer. 
    

    Is this a bug? Is there a better way to get the absolute path of a package?

    • Shahriar

      package_dir and fileinfo are returning null probably because there is no dir and file attached with that package. However if you only attach package dir, then get_package_data($id, 'package_dir'); will return the attached dir path, but still fileinfo var will return null as fileinfo only stores custom file info, like custom file title and file password.

      However, they are actually post meta with prefix __wpdm_ and you can directly read them using get_post_meta function too, int that case you need to add the prefix before variable name, like $path = get_post_meta($id, '__wpdm_package_dir', true);

Leave a Reply