PluginProbe
The GDPR Framework By Data443 / trunk
The GDPR Framework By Data443 vtrunk
2.5.0 2.4.0 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.3 1.0.33 1.0.34 1.0.35 1.0.36 1.0.37 1.0.39 1.0.4 1.0.40 1.0.41 1.0.42 1.0.43 1.0.44 1.0.45 1.0.46 All 41 releases
gdpr-framework / src / Components / WordpressUser / RegistrationForm.php

RegistrationForm.php in The GDPR Framework By Data443 trunk, at src/Components/WordpressUser/RegistrationForm.php

69 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Codelight\GDPR\Components\WordpressUser;
4
5 if ( ! defined( 'ABSPATH' ) ) exit;
6
7 use Codelight\GDPR\DataSubject\DataSubject;
8 use Codelight\GDPR\DataSubject\DataSubjectManager;
9
10 class RegistrationForm
11 {
12 /* @var DataSubjectManager */
13 protected $dataSubjectManager;
14
15 public function __construct(DataSubjectManager $dataSubjectManager)
16 {
17 global $gdpr;
18 $this->dataSubjectManager = $dataSubjectManager;
19 if(!$gdpr->Options->get('register_checkbox')){
20 if ($gdpr->Options->get('policy_page') || $gdpr->Options->get('custom_policy_page')) {
21 add_action('register_form', [$this, 'addRegisterFormCheckbox']);
22 add_filter('registration_errors', [$this, 'validate'], PHP_INT_MAX);
23 }
24 }
25 }
26
27 public function addRegisterFormCheckbox()
28 {
29 global $gdpr;
30 $privacyPolicyUrl = ! get_permalink( gdpr( 'options' )->get( 'custom_policy_page' ) ) ? get_permalink( gdpr( 'options' )->get( 'policy_page' ) ) : get_permalink( gdpr( 'options' )->get( 'custom_policy_page' ) );
31 add_filter( 'gdpr_custom_policy_link', 'gdprfPrivacyPolicyurl' );
32 $privacyPolicyUrl = apply_filters( 'gdpr_custom_policy_link',$privacyPolicyUrl);
33 $termsPage = ! $gdpr->Options->get('custom_terms_page') ? $gdpr->Options->get('terms_page') : $gdpr->Options->get('custom_terms_page');
34
35 if($gdpr->Options->get('custom_terms_page')){
36 $termsPage = $gdpr->Options->get('custom_terms_page');
37 if ($termsPage) {
38 $termsUrl = $termsPage;
39 } else {
40 $termsUrl = false;
41 }
42 }else{
43 $termsPage = $gdpr->Options->get('terms_page');
44 if ($termsPage) {
45 $termsUrl = get_permalink($termsPage);
46 } else {
47 $termsUrl = false;
48 }
49 }
50
51 echo gdpr('view')->render(
52 'modules/wordpress-user/registration-terms-checkbox',
53 compact('privacyPolicyUrl', 'termsUrl')
54 );
55 }
56
57 public function validate(\WP_Error $errors)
58 {
59 if (empty($_POST['gdpr_terms']) || !$_POST['gdpr_terms']) {
60 $errors->add('gdpr_error', __('<strong>ERROR</strong>: You must accept the terms and conditions.', 'gdpr-framework'));
61 } else {
62 $dataSubject = $this->dataSubjectManager->getByEmail($_POST['user_email']);
63 $dataSubject->giveConsent('privacy-policy');
64 }
65
66 return $errors;
67 }
68 }
69