I have been working on a wordpress plugin and have used the do_shortcode() to implement some functionality within a form...a file upload. It works brilliantly, but now I have a problem. I want to assign the name of the file being uploaded to a record within my plugin.
The plugin gave me a call back, that is invoked when the file upload is complete. It passes the names of the files in an array. BUT, I don't have the identification number of the record that I am using and that this file name needs to be assigned to.
Below is a subset of the code I am using to demo the issue
add_shortcode('MMD_SHOW_ENTRY_FORM', 'mmd_vimeo_videoupload');
function mmd_vimeo_videoupload($atts)
{
$OrderId = sanitize_text_field(stripslashes($_GET['or']));
$BillingEmail = sanitize_text_field(stripslashes($_GET['id']));
$FormType = sanitize_text_field(stripslashes($_GET['type']));
$RideCount = sanitize_text_field(stripslashes($_GET['cnt']));
$ListId = sanitize_text_field(stripslashes($_GET['show']));
setcookie("VHSEntryListId", $ListId, time() + ( 3600 * 3)); <<< THROWS ERROR
$_COOKIE['VHSEntryListId'] = $ListId;
setcookie("VHSOrderId", $OrderId, time() + (3600 * 3)); <<< THROWS ERROR
$_COOKIE['VHSOrderId'] = $OrderId ;
setcookie("VHSRideCount", $RideCount, time() + (3600 * 3)); <<< THROWS ERROR
$_COOKIE['VHSRideCount'] = $RideCount;
?>
<form enctype="multipart/form-data" id="RiderEntryForm" name="RiderEntryForm" action="" method="post" autocomplete="off">
<div class="inner-wrap">
do_shortcode("[google_upload]");
</div>
<DIV style="width:100%; "><input type="submit" style="float:left:" id="MMD_SEND_VIDEO" name="MMD_SEND_VIDEO" value="SUBMIT YOUR RIDE"/>
<input type="button" style="" id="MMD_CANCEL_ENTRY" name="MMD_CANCEL_ENTRY" value="GO BACK" onclick="history.back()"/>
</DIV>
</form>
<?php
}
add_action('useyourdrive_upload_post_process', 'mmd_store_upload_information', 10, 2); // Start watching the upload
function mmd_store_upload_information($uploaded_entries, $processor)
{
$ListId = $_COOKIE["VHSEntryListId"]; <<<< NO LONGER WORK IN PHP 8.SetCookie throws error
$OrderId = $_COOKIE["VHSOrderId"]; <<<< NO LONGER WORK IN PHP 8 SetCookie throws error
$RideCount = $_COOKIE["VHSRideCount"]; <<<< NO LONGER WORK IN PHP 8 SetCookie throws error
// retrieve file name from uploaded_entries
$entries = (array)$uploaded_entries;
foreach ($entries as $cached_node)
{
$Node = (array)$cached_node;
if(empty($Node['name']))
continue;
$UploadedFileName = $Node['name'];
$DownloadLink = $Node['direct_download_link'];
mmd_StoreUploadedFileName( $ListId, $OrderId, $RideCount, $UploadedFileName, $DownloadLink );
break;
}
}
WHAT I HAVE TRIED:
setting Cookies, but since it is not in the header, it is throwing warnings and not storing the cookie value. (Seen above).
Global variables are out, since I could have multiple users entering data at the same time.
Reading the URL parameters, from the page that the shortcode is set on...the callback does not know what that is and the $_Get() fails.
So I wonder, if there is anyway to "add parameters" to the 3rd party callback function? Passing these variables to be recieved when the upload is finished from the other plugin.
Thoughts, Ideas??? Presently I am out of ideas. Need help!