PluginProbe
The GDPR Framework By Data443 / 2.1.0
The GDPR Framework By Data443 v2.1.0
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 2.1.0, at src/Components/WordpressUser/RegistrationForm.php

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