Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Hinzufügen eines GDPR-Kommentar-Datenschutz-Opt-in-Kontrollkästchens in WordPress

Hinweis der Redaktion: Wir erhalten eine Provision für Partnerlinks auf WPBeginner. Die Provisionen haben keinen Einfluss auf die Meinung oder Bewertung unserer Redakteure. Erfahre mehr über Redaktioneller Prozess.

Möchten Sie ein GDPR-Kontrollkästchen für den Datenschutz bei Kommentaren in WordPress hinzufügen?

Das GDPR-Gesetz der Europäischen Union besagt, dass Sie die ausdrückliche Zustimmung zur Speicherung der personenbezogenen Daten eines Nutzers einholen müssen. Wenn Sie auf Ihrer Website Kommentare aktiviert haben, müssen Sie ein Kontrollkästchen für den Datenschutz bei Kommentaren hinzufügen, um die GDPR-Vorschriften einzuhalten und eine hohe Geldstrafe zu vermeiden.

In diesem Artikel zeigen wir Ihnen, wie Sie ein GDPR-Kontrollkästchen für den Datenschutz zu Ihrer WordPress-Website hinzufügen können.

How to add comment privacy optin checkbox in WordPress

Warum ein Kommentar Datenschutz Opt-in Checkbox in WordPress hinzufügen?

Die allgemeine Datenschutzverordnung (GDPR) soll den EU-Bürgern mehr Kontrolle über ihre persönlichen Daten geben.

Als dieses Gesetz eingeführt wurde, änderte es die Herangehensweise vieler Organisationen an den Datenschutz. Weitere Informationen zu diesem Thema finden Sie in unserem ultimativen Leitfaden für WordPress und die Einhaltung der GDPR.

Wenn Sie die GDPR nicht einhalten, können Sie mit einer Geldstrafe oder sogar einer Gefängnisstrafe belegt werden. Deshalb sollte jeder Teil Ihrer Website GDPR-konform sein, auch Ihr Kommentarformular.

Ein Kommentarformular sammelt persönliche Informationen von Besuchern, einschließlich ihrer Namen und E-Mail-Adressen. WordPress speichert diese Informationen auch in einem Browser-Cookie, so dass es die Informationen des Benutzers in Zukunft automatisch ausfüllen kann.

Standardmäßig zeigt das WordPress-Kommentarformular ein Kontrollkästchen für den Datenschutz an.

The GDPR compliance checkbox, in a WordPress comment form

Wenn Sie dieses Kontrollkästchen auf Ihrer Website jedoch nicht sehen, ist es möglicherweise in Ihrem WordPress-Theme deaktiviert.

Wie man das Opt-in-Kontrollkästchen für den Kommentarschutz in WordPress aktiviert

Bevor Sie Ihre eigene Datenschutzbox für Kommentare erstellen, sollten Sie prüfen, ob Ihr Theme diese Funktion bereits integriert hat.

Prüfen Sie zunächst, ob Ihr Theme und der WordPress-Kern auf dem neuesten Stand sind, indem Sie auf Dashboard “ Updates gehen.

Check for WordPress and theme updates

Wenn Aktualisierungen verfügbar sind, installieren Sie sie einfach. Wenn Sie Hilfe benötigen, lesen Sie bitte unseren Leitfaden für die sichere Aktualisierung von WordPress.

Gehen Sie danach auf Einstellungen “ Diskussion und scrollen Sie zu „Andere Kommentareinstellungen“. Aktivieren Sie hier das Kontrollkästchen neben „Opt-in-Kontrollkästchen für Kommentar-Cookies anzeigen….“.

Enabling the GDPR checkbox in WordPress settings

Klicken Sie dann einfach auf „Änderungen speichern“, um Ihre Einstellungen zu speichern.

Jetzt können Sie Ihre WordPress-Website besuchen, um zu sehen, ob diese Änderungen das fehlende Kontrollkästchen hinzugefügt haben.

Clicking the 'Save Changes' button on the WordPress Discussion settings page

Wenn Sie auf dem neuesten Stand sind und das Kontrollkästchen für den Datenschutz bei Kommentaren immer noch nicht sehen können, dann bedeutet dies, dass Ihr Theme das Standard-WordPress-Kommentarformular außer Kraft setzt.

Wir empfehlen daher, den Entwickler des Themes zu bitten, dieses Problem zu beheben, indem Sie ein Support-Ticket eröffnen. Ratschläge finden Sie in unserem Leitfaden für die richtige Anfrage an den WordPress-Support.

Eine andere Möglichkeit besteht darin, das Kontrollkästchen für den Kommentarschutz selbst in Ihr WordPress-Theme einzufügen. Es gibt verschiedene Möglichkeiten, dies zu tun. Verwenden Sie die unten stehenden Links, um direkt zu der gewünschten Methode zu gelangen:

Hinweis: Bevor Sie die nachstehenden Anleitungen befolgen, empfehlen wir Ihnen dringend, eine Sicherungskopie Ihrer Website zu erstellen, für den Fall, dass unerwartete Fehler auftreten. Sie können ein Backup-Plugin wie Duplicator verwenden.

Außerdem empfehlen wir, ein Child-Theme zu erstellen, da Sie so Ihr WordPress-Theme aktualisieren können, ohne dass die Anpassungen verloren gehen.

Methode 1: Fügen Sie Ihrem WordPress-Theme ein Kontrollkästchen für den Kommentarschutz hinzu (empfohlen)

Sie können dem Kommentarformular Ihres Themes mit Hilfe von benutzerdefiniertem Code ein Kontrollkästchen für den Datenschutz hinzufügen.

Bei dieser Methode müssen Sie Ihre Themadateien bearbeiten, sie ist also nicht besonders anfängerfreundlich. Sie sollte jedoch für die meisten WordPress-Themes funktionieren. Außerdem bleiben der Formularstil und das Layout Ihres Themes intakt.

Zunächst müssen Sie sich mit einem FTP-Client wie FileZilla mit Ihrer WordPress-Website verbinden, oder Sie können den Dateimanager Ihres WordPress-Hosting-CPanels verwenden. Wenn Sie ein SiteGround-Kunde sind, können Sie den Dateimanager im Dashboard der Site Tools verwenden.

Wenn Sie FTP zum ersten Mal verwenden, lesen Sie bitte unsere vollständige Anleitung, wie Sie sich mit Ihrer Website per FTP verbinden.

Sobald Sie verbunden sind, müssen Sie zu /wp-content/themes/ gehen und den Ordner für Ihr aktuelles WordPress-Theme öffnen.

Accessing your theme files using FTP

Sie müssen den Code finden, der das Standard-WordPress-Kommentarformular außer Kraft setzt. Normalerweise finden Sie diesen Code in der Datei comments.php oder functions.php in Ihrem Theme-Ordner.

Nachdem Sie eine dieser Dateien geöffnet haben, suchen Sie nach Code, der den Filter comment_form_default_fields enthält. Themes verwenden diesen Filter, um das Standard-WordPress-Kommentarformular außer Kraft zu setzen.

Er enthält Zeilen für alle Felder Ihres Kommentarformulars. Jedes Theme ist anders, aber hier ist ein Beispiel für den Code, nach dem Sie suchen:

$comments_args = array(
            // change the title of send button
            'label_submit'=> esc_html(__('Post Comments','themename')),
            // change the title of the reply section
            'title_reply'=> esc_html(__('Leave a Comment','themename')),
            // redefine your own textarea (the comment body)
            'comment_field' => '
            <div class="form-group"><div class="input-field"><textarea class="materialize-textarea" type="text" rows="10" id="textarea1" name="comment" aria-required="true"></textarea></div></div>',
 
            'fields' => apply_filters( 'comment_form_default_fields', array(
                'author' =>'' .
                  '<div><div class="input-field">' .
                  '<input class="validate" id="name" name="author" placeholder="'. esc_attr(__('Name','themename')) .'" type="text" value="' . esc_attr( $commenter['comment_author'] ) .
                  '" size="30"' . $aria_req . ' /></div></div>',
 
                'email' =>'' .
                  '<div><div class="input-field">' .
                  '<input class="validate" id="email" name="email" placeholder="'. esc_attr(__('Email','themename')) .'" type="email" value="' . esc_attr(  $commenter['comment_author_email'] ) .
                  '" size="30"' . $aria_req . ' /></div></div>',
 
                'url' =>'' .
                  '<div class="form-group">'.
                  '<div><div class="input-field"><input class="validate" placeholder="'. esc_attr(__('Website','themename')) .'" id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) .
                  '" size="30" /></div></div>',
                )
            ),
        );
 
    comment_form($comments_args);   ?> 

In diesem Code werden Sie feststellen, dass der Filter comment_form_default_fields verwendet wird, um die Felder author, email und URL zu ändern.

Es zeigt jedes Feld in folgendem Format an:

'fieldname' => 'HTML code to display the field',
'anotherfield' => 'HTML code to display the field',

Jetzt fügen wir das Feld für das Ankreuzen des Datenschutzes am Ende des Codeblocks vor der Zeile comment_form($comments_args); ?> hinzu.

So sollte der Code jetzt aussehen, aber Sie können den Code einfach kopieren und aus dem // Jetzt fügen wir unseren neuen Datenschutz-Kontrollkästchen-Opt-in-Kommentar hinzu:

$comments_args = array(
            // change the title of send button
            'label_submit'=> esc_html(__('Post Comments','themename')),
            // change the title of the reply section
            'title_reply'=> esc_html(__('Leave a Comment','themename')),
            // redefine your own textarea (the comment body)
            'comment_field' => '
            <div class="form-group"><div class="input-field"><textarea class="materialize-textarea" type="text" rows="10" id="textarea1" name="comment" aria-required="true"></textarea></div></div>',
 
            'fields' => apply_filters( 'comment_form_default_fields', array(
                'author' =>'' .
                  '<div><div class="input-field">' .
                  '<input class="validate" id="name" name="author" placeholder="'. esc_attr(__('Name','themename')) .'" type="text" value="' . esc_attr( $commenter['comment_author'] ) .
                  '" size="30"' . $aria_req . ' /></div></div>',
 
                'email' =>'' .
                  '<div><div class="input-field">' .
                  '<input class="validate" id="email" name="email" placeholder="'. esc_attr(__('Email','themename')) .'" type="email" value="' . esc_attr(  $commenter['comment_author_email'] ) .
                  '" size="30"' . $aria_req . ' /></div></div>',
 
                'url' =>'' .
                  '<div class="form-group">'.
                  '<div><div class="input-field"><input class="validate" placeholder="'. esc_attr(__('Website','themename')) .'" id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) .
                  '" size="30" /></div></div>',
 
// Now we will add our new privacy checkbox opt-in
 
                'cookies' => '<p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"' . $consent . ' />' .
                                             '<label for="wp-comment-cookies-consent">' . __( 'Save my name, email, and website in this browser for the next time I comment.' ) . '</label></p>',
                )
            ),
        );
 
    comment_form($comments_args);   ?> 

Nachdem Sie diese Änderung vorgenommen haben, speichern Sie die Datei und laden Sie sie wieder auf Ihr WordPress-Hosting-Konto hoch.

Wenn Sie fertig sind, können Sie Ihren WordPress-Blog besuchen, um die Änderungen in Aktion zu sehen.

Methode 2: Ersetzen Sie das Kommentarformular Ihres Themes durch das WordPress-Standardformular

Bei dieser Methode wird einfach das Kommentarformular Ihres Themes durch das Standard-WordPress-Kommentarformular ersetzt.

Diese Methode kann das Aussehen des Kommentarformulars verändern. Sie ist daher nicht die beste Methode, wenn Sie den Stil und das Layout des Formulars beibehalten möchten. Nachdem Sie diese Änderung vorgenommen haben, können Sie Ihr Kommentarformular jedoch jederzeit mit benutzerdefiniertem CSS gestalten.

Wie bei der vorhergehenden Methode müssen Sie sich zunächst per FTP mit Ihrem Server verbinden oder den Dateimanager Ihres Hosts öffnen.

Danach öffnen Sie die Datei comments.php und suchen nach einer Zeile mit der Funktion comment_form(). Ihr Theme hat ein definiertes Argument, eine Funktion oder eine Vorlage, mit der es das benutzerdefinierte Kommentarformular Ihres Themes lädt. Die comment_form-Zeile wird etwa so aussehen:

<?php comment_form( custom_comment_form_function() ); ?>

Sie müssen diese durch die folgende Zeile ersetzen:

<?php comment_form(); ?>

Speichern Sie anschließend Ihre Änderungen.

Wenn Sie nun Ihre Website besuchen, sehen Sie das Standard-WordPress-Kommentarformular mit dem Kontrollkästchen für den Datenschutz bei Kommentaren.

The default WordPress comment form

Bonus-Tipp: Verbessern Sie die Einhaltung der GDPR mit MonsterInsights

Die Aktivierung einer Checkbox für den Datenschutz bei Kommentaren ist eine Möglichkeit, Ihre Website GDPR-konformer zu machen. Wenn Sie andere Daten sammeln und sicherstellen wollen, dass Ihre Website die GDPR einhält, dann empfehlen wir die Installation von MonsterInsights.

MonsterInsights ist ein Plugin, das es einfach macht, Ihre Website mit Google Analytics zu verbinden. Darüber hinaus verfügt es über ein EU-Compliance-Add-on, damit Ihr Tracking der GDPR entspricht.

Damit wartet MonsterInsights auf die Zustimmung des Nutzers, seine Aktivitäten zu verfolgen, anstatt dies zu tun, sobald er auf Ihrer Seite ankommt.

MonsterInsights EU compliance addon

Für weitere Informationen über MonsterInsights lesen Sie bitte unseren MonsterInsights Testbericht und unsere Liste der besten WordPress GDPR-Plugins.

Wir hoffen, dass dieser Artikel Ihnen geholfen hat zu lernen, wie Sie das GDPR-Kontrollkästchen für den Datenschutz in WordPress hinzufügen können. Vielleicht interessieren Sie sich auch für unseren Leitfaden, wie Sie eine Benutzerregistrierung auf Ihrer WordPress-Website zulassen, und für unsere Expertenauswahl der besten Kontaktformular-Plugins.

Wenn Ihnen dieser Artikel gefallen hat, dann abonnieren Sie bitte unseren YouTube-Kanal für WordPress-Videotutorials. Sie können uns auch auf Twitter und Facebook finden.

Offenlegung: Unsere Inhalte werden von unseren Lesern unterstützt. Das bedeutet, dass wir möglicherweise eine Provision verdienen, wenn Sie auf einige unserer Links klicken. Mehr dazu erfahren Sie unter Wie WPBeginner finanziert wird , warum das wichtig ist und wie Sie uns unterstützen können. Hier finden Sie unseren redaktionellen Prozess .

Das ultimative WordPress Toolkit

Erhalte KOSTENLOSEN Zugang zu unserem Toolkit - eine Sammlung von WordPress-bezogenen Produkten und Ressourcen, die jeder Profi haben sollte!

Reader Interactions

34 KommentareEine Antwort hinterlassen

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Kris says

    What I just don’t understand or maybe I am missing something, is how to put the Privacy Policy checkbox as in what you have on your comments. Something like, „by using this form you agree to us collecting and storing data as per our privacy policy. Nobody seems to have this information – just the usual comment checkbox which is straight forward to do.

    • WPBeginner Support says

      If I understand what you’re looking to do, you can change the text by editing the text on line 29 in our code above that currently has ‚Save my name, email, and website in this browser for the next time I comment.‘ when replacing, ensure you keep the single quotes.

      Admin

  3. mike carpenter says

    Got this working and checked that the cookie was being created as expected, but when I browse away from the blog page and then return to it, I expected the form values to be pre-populated with the values stored in the cookie, but this doesn’t happen and the fields are left blank! I think I assumed that the line $commenter = wp_get_current_commenter(); and subsequent lines esc_attr( $commenter[‚comment_author_url‘] ) etc. would retrieve the stored field values from the cookie. Have I missed something, or am I msundersatding the way the checkbox is supposed to work?

  4. Tara says

    I normally find great info on your site, but I have to speak up and say in this case, this is not accurate to be ready for GDPR, you need get consent to save their data for the comment/email/name/ip etc in your website database, whether or not they choose to save their details in a cookie for faster commenting at a later time.

    I used css to hide this checkmark and installed a GDPR plugin, unfortunately now that plugin is not prompting people that they have to checkmark to leave their comment, so now we are losing comments. What’s also frustrating is that it appears for all users with no option to show only for EU. Another frustration is that with hiding the wordpress added checkmark, now the users do not see „your comment is awaiting moderation“.

  5. Mirko says

    What if I don’t want the commenters to store a cookie with their personal data at all? Is there a way to deactivate the whole process and to hide this cookie consent for good?

  6. Uphoria says

    What if the code is there in my theme already? It’s still not showing up, but it has each of the fields there.

  7. Peter says

    Thx for the guide,

    but everything described doesn’t seem to be possible, if it’s a wordpress.com page (free/no plan).

    There is no updating and there is nothing in the settings to add an opt-in check box or any other specific code. The only thing in the settings, that implies a possibility to achieve GDPR-compliance is to add a short info, that data will be provided to and stored at automaticc with a link to their privacy disclaimer. Furthermore, plug-ins and access via ftp can not be used.

    Any suggestions on how to include an opt-in check box for users who only use the free wordpress.com solution?
    Or is it not even needed due to the fact that user access to the web space is only possible via the rather limited wordpress configuration page – or due to any other means?

  8. Bryan says

    Hello, I was able to add this in my theme and it works, but there is one problem. I check consent box. Next time, my name and email are filled in, but I have to check consent box again. In default WP theme, if I check remember name, email fields box once, next time it comes checked by default. Is there problem with my theme or this code can be improved?

  9. Jim says

    Hey there! Great instruction! I am trying to get some sites GDPR compliant as well.

    I was wondering about Genesis websites, I couldn’t find this code in either comments.php OR functions.php so I first tried loading the code from Method 1 in via Simple Hooks after the comment form then I used the code you gave to Mateja in my functions.php. Both gave me a checkbox but… is it supposed to do anything else? Is there somewhere that I can see whether a commenter has checked this box? Thanks in advance for any help.

    Jim

  10. Elisa says

    Unfortunately I cannot apply any of the mentioned solutions as none of the CSS can be found. Contacted the comoany I got my theme from, hope they can help.

  11. Alexander says

    Hi,
    I was not helped by Method 1 and Method 2.
      I could not find the code I needed to edit.

    I’m using the „publisher“ (themeforest) template.

    Can you tell me how to configure the „publisher“ template?
    Thank you

    • WPBeginner Support says

      Hi Alexander,

      Unfortunately, it is not possible for us to come up with a solution for each theme as they use different methods. It would be best to contact your theme developer for support.

      Admin

  12. Samantha says

    I also got the „Undefined variable: consent“ message when I tried to do this, although the checkbox appeared along with the message.

  13. Mateja says

    Hi, I disabled the Jetpack comment form and now I can see the checkbox. All good. BUT, I don’t like how the text looks like….save my name, address and so on…..I would like to insert my own text with a link to the privacy policy,,,,,….is that possible? and how I do that? Thank you

    • WPBeginner Support says

      Hi Mateja,

      You can try this code in your theme’s functions.php file. You’ll be able to change the label text for the consent checkbox.

      function wpb_comments_privacy($arg) {
         
        $arg['cookies'] = '<p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"' . $consent . ' />' .
                                                   '<label for="wp-comment-cookies-consent">' . __( 'Save my name, email, and website in this browser for the next time I comment.' ) . '</label></p>';
           
        return $arg;
      }
       
      add_filter('comment_form_default_fields', 'wpb_comments_privacy');
      

      Admin

  14. Kamran Khan says

    Thank you sir. I have applied the 1st method. Its working but after inserting the code some of the code elements also shown with the checkbox and message which I manually removed. Is it OK? Now its working fine but the checkbox is showing above the message and not inline. How I can inline both the checkbox and the message.

    • WPBeginner Support says

      Hi Kamran,

      No, there is probably something missing in the code. Most likely a quote or a php start or end tag. Carefully review the code to make sure that all quotes are closed and code is properly formatted.

      For styling you will need to use custom CSS to adjust the field.

      Admin

  15. Carey says

    Ok, I am ignorant about adding code. I am using the K2 theme, which does not seem to have the updated comments form. I installed Code Snippets, but I don’t understand – does it just know where to put the snippet? I looked at the comments code in the theme files, but it doesn’t look anything like your example here. In fact it has 189 lines of code for comments. Do I just add your „new privacy checkbox optin“ code to snippets and click activate and it inserts it in the correct place? So confused…

  16. Brian Sanderson says

    Hi! I do not have the above code in your article, as is, but i do have the following code in the comments.php file. The code includes the 4 fields;

    Could you please advise how my code could be edited? Thanks in advance.

    • WPBeginner Support says

      Hi Brian,

      It depends on rest of the code in your theme. Unfortunately, we cannot cover all the possible ways in which a theme may display a comment form. You will need to reach out to your theme author for support.

      Admin

  17. Thomas says

    I tried using this and got the following notice in place of the checkbox:

    Undefined variable: consent

    So you didn’t define it? How do I do that?

    • Mark Corder says

      Huh… It’s working for me. I just need to get the checkbox and label lined-up to match the rest of my form…

    • Thomas says

      Just so everyone knows I opened up comments-template.php file from the wp-includes folder and found this:

      $consent = empty( $commenter[‚comment_author_email‘] ) ? “ : ‚ checked=“checked“‚;

      Adding this to the above defines the consent and in doing so will remove the notice if you have debug turned on.

      You have to add it before the $comments_args = array. This all depends on how you have your template configured.

      Hope it helps.

Eine Antwort hinterlassen

Danke, dass du einen Kommentar hinterlassen möchtest. Bitte beachte, dass alle Kommentare nach unseren kommentarpolitik moderiert werden und deine E-Mail-Adresse NICHT veröffentlicht wird. Bitte verwende KEINE Schlüsselwörter im Namensfeld. Lass uns ein persönliches und sinnvolles Gespräch führen.