How can I retrieve the Post or Page ID and store it in a variable to be used anywhere like within a shortcode processing data?
I have a function that processes a download button and would like to store the Page/Post ID that the download was processed together with timestamp in order that I do some tracking on which page/post the download was made.
Here is the data that is currently being stored and I would like to add the post_ID() data as well...
$data_id = $wpdb->get_row("select * from ahm_files where id='$id'",ARRAY_A);
$wpdb->insert('wp_ahm_download_stats',array('pid'=>$data['id'], 'month_of_download'=>date('Y-M'),'year'=>date('Y'),'month'=>date('m'),'day'=>date('d'), 'timestamp'=>time(), 'ip'=>$ip),array('%s','%s','%s','%s','%s'));]
Thank you,
Eric
This is part of the code of the processing function..
else {
$id = (int)$id;
$data = $wpdb->get_row("select * from ahm_files where id='$id'",ARRAY_A);
}
if($data['download_count']>=$data['quota']&&$data['quota']>0) wp_die('Download Limit Excedded!');
//added for download monitor import feature
$data['file'] = str_replace(site_url('/'),ABSPATH, $data['file']);
if(strpos($data['file'],'ttp://')){
header("location: ".$data['file']);
die();
}
$data['file'] = trim($data['file']);
if(file_exists($data['file']) && $data['file']!= "")
$fname = $data['file'];
else if(file_exists(UPLOAD_DIR . $data['file']) && $data['file']!= "")
$fname = UPLOAD_DIR . $data['file'];
else if( $data['file']== "")
wp_die("No file attached yet.");
else
wp_die('File not found!');
$wpdb->query("update ahm_files set download_count=download_count+1 where id='$data[id]'");
$wpdb->insert('wp_ahm_download_stats',array('pid'=>$data['id'], 'month_of_download'=>date('Y-M'),'year'=>date('Y'),'month'=>date('m'),'day'=>date('d'), 'timestamp'=>time(), 'ip'=>$ip),array('%s','%s','%s','%s','%s'));
$filetype = wp_check_filetype($fname);
$mtype = $filetype['type'];
$asfname = basename($fname);
$fsize = filesize($fname);