I have created a custom post type which will store posts that contain videos, i have made use of the ACF wysiwyg field to display the video content and i have a further true/false field which will enable/disable the video. Basically if it is enabled, it will display the video on the page and if it is disabled then it won't display on the page.
Now for the tricky part, when a video is disabled i need to either rename the file on the server or move it to a temporary location. If there are other options, i am open to ideas. The requirement for this is so that they can have control of when the video is viewed.
If the video is shared on Facebook, you would normally be able to still view that video regardless because it would still exist on the server, however we need to be able to control that. If i share a video today and disable it tomorrow, no one else clicking on the link for that video should be able to view it until it is enabled again.
I tried using a rename function but i don't think that is the best way of doing this, as if i enable the video again it would need to have the same name as before it was disabled. Perhaps there is another way of achieving what i need to do?
Video path comes from my ACF field. (The wysiwyg editor)
function jd_video_path($video_path) {
global $wpdb;
$video_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE guid='%s';", $video_path ) );
$post = get_post($video_id);
$file = get_attached_file($video_id);
$path = pathinfo($file);
$new_file_name = "offline";
$new_file = $path['dirname']."/".$new_file_name.".".$path['extension'];
rename($file, $newfile);
update_attached_file( $video_id, $new_file );
var_dump($path);
}