2018-05-22 11:17:18 +03:00
|
|
|
<?php
|
|
|
|
|
namespace um\core;
|
|
|
|
|
|
2019-10-17 21:44:11 +03:00
|
|
|
|
2018-05-22 11:17:18 +03:00
|
|
|
if ( ! defined( 'ABSPATH' ) ) exit;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( ! class_exists( 'um\core\GDPR' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class Admin_GDPR
|
|
|
|
|
* @package um\core
|
|
|
|
|
*/
|
|
|
|
|
class GDPR {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Admin_GDPR constructor.
|
|
|
|
|
*/
|
|
|
|
|
function __construct() {
|
|
|
|
|
add_action( 'um_submit_form_register', array( &$this, 'agreement_validation' ), 9 );
|
|
|
|
|
|
2019-05-08 16:05:27 +03:00
|
|
|
add_filter( 'um_before_save_filter_submitted', array( &$this, 'add_agreement_date' ), 10, 2 );
|
2018-05-22 11:17:18 +03:00
|
|
|
add_filter( 'um_email_registration_data', array( &$this, 'email_registration_data' ), 10, 1 );
|
|
|
|
|
|
|
|
|
|
add_action( 'um_after_form_fields', array( &$this, 'display_option' ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param $args
|
|
|
|
|
*/
|
|
|
|
|
function display_option( $args ) {
|
|
|
|
|
if ( isset( $args['use_gdpr'] ) && $args['use_gdpr'] == 1 ) {
|
|
|
|
|
require um_path . 'templates/gdpr-register.php';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param $args
|
|
|
|
|
*/
|
|
|
|
|
function agreement_validation( $args ) {
|
|
|
|
|
$gdpr_enabled = get_post_meta( $args['form_id'], '_um_register_use_gdpr', true );
|
|
|
|
|
|
|
|
|
|
if ( $gdpr_enabled && ! isset( $args['submitted']['use_gdpr_agreement'] ) ) {
|
|
|
|
|
UM()->form()->add_error( 'use_gdpr_agreement', isset( $args['use_gdpr_error_text'] ) ? $args['use_gdpr_error_text'] : '' );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param $submitted
|
2019-05-08 16:05:27 +03:00
|
|
|
* @param $args
|
2018-05-22 11:17:18 +03:00
|
|
|
*
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
2019-05-08 16:05:27 +03:00
|
|
|
function add_agreement_date( $submitted, $args ) {
|
2018-05-22 11:17:18 +03:00
|
|
|
if ( isset( $submitted['use_gdpr_agreement'] ) ) {
|
|
|
|
|
$submitted['use_gdpr_agreement'] = time();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $submitted;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param $submitted
|
|
|
|
|
*
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
function email_registration_data( $submitted ) {
|
|
|
|
|
if ( ! empty( $submitted['use_gdpr_agreement'] ) ) {
|
2018-10-18 10:09:29 +03:00
|
|
|
$timestamp = ! empty( $submitted['timestamp'] ) ? $submitted['timestamp'] : $submitted['use_gdpr_agreement'];
|
|
|
|
|
|
2018-05-22 11:17:18 +03:00
|
|
|
$submitted['GDPR Applied'] = date( "d M Y H:i", $timestamp );
|
|
|
|
|
unset( $submitted['use_gdpr_agreement'] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $submitted;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|