0
0
Wordpressframework~10 mins

Privacy and GDPR settings in Wordpress - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to enable the WordPress privacy policy page.

Wordpress
add_filter('wp_privacy_policy_content', function() { return [1]; });
Drag options to blanks, or click blank then click option'
Atrue
B'Your privacy policy content here'
C''
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a boolean value instead of a string.
Leaving the content empty.
2fill in blank
medium

Complete the code to register a new GDPR consent checkbox in a WordPress form.

Wordpress
add_action('comment_form_logged_in_after', function() { echo '<p class="comment-form-consent"><input type="checkbox" name="gdpr_consent" value="1" required> [1]</p>'; });
Drag options to blanks, or click blank then click option'
A"Remember my details."
B"Subscribe me to the newsletter."
C"I accept cookies."
D"I agree to the terms and conditions."
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated checkbox labels.
Not marking the checkbox as required.
3fill in blank
hard

Fix the error in the code to properly add a GDPR consent field to the user registration form.

Wordpress
add_action('register_form', function() { ?> <p><label for="gdpr_consent">[1]<input type="checkbox" name="gdpr_consent" id="gdpr_consent" value="1" required></label></p> <?php });
Drag options to blanks, or click blank then click option'
A"I accept the privacy policy."
B"Accept privacy policy"
C"Privacy policy accepted"
D"Privacy policy"
Attempts:
3 left
💡 Hint
Common Mistakes
Using incomplete or unclear label text.
Not associating the label with the checkbox input.
4fill in blank
hard

Fill both blanks to create a shortcode that displays the privacy policy link with proper text.

Wordpress
function privacy_link_shortcode() { return '<a href="' . [1] . '">' . [2] . '</a>'; } add_shortcode('privacy_link', 'privacy_link_shortcode');
Drag options to blanks, or click blank then click option'
Aget_privacy_policy_url()
B"Privacy Policy"
C"Terms of Service"
Dsite_url()
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong URL function.
Using incorrect link text.
5fill in blank
hard

Fill all three blanks to create a function that saves GDPR consent meta data when a user registers.

Wordpress
function save_gdpr_consent_meta([1]) { if (isset($_POST['gdpr_consent'])) { update_user_meta([2], 'gdpr_consent', [3]); } } add_action('user_register', 'save_gdpr_consent_meta');
Drag options to blanks, or click blank then click option'
A$user_id
C1
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variable names.
Saving the wrong value for consent.