[ad_1]
[ad_2]
Hi guys! I have this WordPress site where I use woocommerce for payments. Once a payment is done and the order is complete, a presigned url is generated from R2 bucket in cloudflare and it is appended to the URL of the page that streams the video:
<?php
/*
Template Name: Movie Player
*/
get_header();
$url = isset($_GET['url']) ? esc_url($_GET['url']) : '';
if ($url):
echo '<pre>';
print_r($url); // Print the final URL for debugging
echo '</pre>';
?>
<video controls controlsList="nodownload">
<source src="<?php echo $url; ?>" type="video/mp4">
Your browser does not support the video tag.
</video>
<script>
document.addEventListener('DOMContentLoaded', function() {
const video = document.querySelector('video');
video.addEventListener('contextmenu', function(e) {
e.preventDefault(); // Disable right-click context menu
});
// Log the video URL to the console
console.log("Video URL:", "<?php echo $url; ?>");
});
</script>
<?php
else:
echo 'No video URL provided.';
endif;
get_footer();
function handle_order_complete($order_id) {
$order = wc_get_order($order_id);
if ($order->has_status('completed')) {
// Retrieve the bucket name and object key from environment variables
$bucketName = 'ngop-movie';
$objectKey = 'kot-2-movie.mp4';
// Generate the pre-signed URL
$presignedUrl = generate_presigned_url($bucketName, $objectKey);
// Redirect the user to the movie player page with the pre-signed URL
wp_redirect('https://kotthemovie.com/movie-stream?url=' . urlencode($presignedUrl));
exit;
}
}
This is the code that does this part in functions.php.
Then in my video player page I retreive the parameter from the url and use it as source in my video player to stream the video. It works fine locally with localhost but on my deployed wordpress site in wp engine I am not able to retrieve the parameter and add it to the source of the video. The vdideo player doesnt show at all. Can anyone please help me resolve this issue?

On the live version, what exactly is happening? Are you seeing your print_r of the video URL? Are you seeing your
echo ‘No video URL provided.’;
What exactly are you seeing on the live page?
The issue seems to be related to how the parameter is being retrieved in WP Engine compared to local development.
For troubleshooting:
Check URL Redirection: Ensure WP Engine is correctly passing query parameters.
Disable caching: WP Engine’s caching may strip query parameters.
Use Debugging: Add debug output, like print_r($_GET);, to see if the url parameter is being received correctly.