Site icon Hip-Hop Website Design and Development

Add parameters to 3rd party callback function

I have been working on a WordPress plugin and have used the do_shortcode() to implement some functionality within a form…a file upload. The upload processing comes from a 3rd party plugin and It works brilliantly.

BUT now I have a problem. I want to assign the name of the file being uploaded to a record in the database, within my plugin. However the identifiers to that db record is not presently available within the callback hook, provided by the 3rd party.

This used to work, thought the use of cookies, but since the upgrade to a newer PHP version, the process fails as of now.

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:

  1. setting Cookies, but since it is not in the header, it is throwing warnings and not storing the cookie value. (Seen above).

  2. Global variables are out, since I could have multiple users entering data at the same time.

  3. 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!