Support

Account

Home Forums General Issues Update oEmbed field with YouTube no cookie url?

Solved

Update oEmbed field with YouTube no cookie url?

  • Is there any way at all to do this in ACF? With GDPR regulations, it’s very important. So far, I’ve been able to update the URL string in the database on save, but after that it renders as a string, rather than inserting the iframe.

    	function miunus6db_youtube_nocookie( $post_id ) {
    
    		if( get_field('video', $post_id) ) {
    
    			$url = get_field('video', $post_id, false);
    
    			$url = str_replace( 'youtube.com/watch?v=', 'youtube-nocookie.com/embed/', get_field('video', $post_id, false));
    
    			update_field('video', $url, $post_id);
    		}
    	}
    	
    	add_action('acf/save_post', 'miunus6db_youtube_nocookie', 25);
  • Putting this in the template file is the best I could come up with. However, now I’m not stoked that YouTube drops a cookie even from the no-cookie URL….

    		<?php 
    			$iframe = get_field('video');
    			$iframe = str_replace('youtube.com/embed/', 'youtube-nocookie.com/embed/', $iframe);
    		?>
    
    		<div class="minus6db-video"><?php echo $iframe ?></div>
  • This reply has been marked as private.
  • Sorry, which file did you edit?
    I have added first code to functions.php and second post code to page php file.
    This however did absolutely 0 difference when loading videos without accepting cookies.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Update oEmbed field with YouTube no cookie url?’ is closed to new replies.