GDPR (DSGVO) is a tricky beast. If you’re building a BuddyPress powered website in Europe, or plan to serve European visitors, you may need to consider the YouTube embed cookie issue. As it stands the embed will automatically set a cookie for embedded YouTube videos whether you wish to or not.

You can resolve this by converting all youtube.com urls to youtube-nocookie.com urls with the below code. Simply copy and paste this snippet below into your child themes functions.php file and save. If you don’t have a child theme you can add this in the bp-custom.php file.

function translate_youtube_url_gdpr($translated)
{
    $translated = str_ireplace('youtube.com/embed/', 'youtube-nocookie.com/embed/', $translated);
    return $translated;
}
add_filter('bp_embed_oembed_html', 'translate_youtube_url_gdpr');

Once you have saved the snippet, clear all of your caches and inspect the YouTube embed. You should now see all urls have been converted from youtube.com to youtube-nocookie.com.

Leave a comment

In response to:

GDPR Compliant YouTube embeds for BuddyPress

Your email address will not be published. Required fields are marked *

*