PluginProbe
LoginPress | wp-login Custom Login Page Customizer / trunk
LoginPress | wp-login Custom Login Page Customizer vtrunk
6.2.5 6.2.4 6.2.3 6.2.2 6.2.1 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.3 1.0.4 All 118 releases
loginpress / include / privacy-policy.php

privacy-policy.php in LoginPress | wp-login Custom Login Page Customizer trunk, at include/privacy-policy.php

74 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * LoginPress Privacy Policy Functions.
4 *
5 * This file contains functions for privacy policy settings.
6 * Purpose of this file is to add privacy policy field to registration form and validate user acceptance.
7 *
8 * @package LoginPress
9 * @since 1.0.19
10 * @version 6.2.0
11 */
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 // Add privacy policy field.
18 add_action( 'register_form', 'loginpress_add_privacy_policy_field' );
19
20 // Add validation. In this case, we make sure lp_privacy_policy is required.
21 add_filter( 'registration_errors', 'loginpress_privacy_policy_auth', 10, 3 );
22
23 /**
24 * Add privacy policy field.
25 *
26 * @since 1.0.19
27 * @return void
28 */
29 function loginpress_add_privacy_policy_field() {
30
31 $loginpress_setting = get_option( 'loginpress_setting' );
32 $privacy_policy = isset( $loginpress_setting['privacy_policy'] ) ? $loginpress_setting['privacy_policy'] : __( sprintf( __( '%1$sPrivacy Policy%2$s.', 'loginpress' ), '<a href="' . admin_url( 'admin.php?page=loginpress-settings' ) . '">', '</a>' ), 'loginpress' ); // @codingStandardsIgnoreLine.?>
33 <p>
34 <label for="lp_privacy_policy"><br />
35 <input type="checkbox" name="lp_privacy_policy" id="lp_privacy_policy" class="checkbox" />
36 <?php echo wp_kses_post( $privacy_policy ); ?>
37 </label>
38 </p>
39 <?php
40 }
41
42
43 /**
44 * Add validation. In this case, we make sure lp_privacy_policy is required.
45 *
46 * @since 1.0.19
47 * @param WP_Error $errors The privacy auth error.
48 * @return WP_Error
49 */
50 function loginpress_privacy_policy_auth( $errors ) {
51 if ( ! isset( $_POST['lp_privacy_policy'] ) ) : // phpcs:ignore
52 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- This is called during registration process where nonce is already verified.
53 $errors->add( 'policy_error', esc_html__( 'ERROR: Please accept the privacy policy.', 'loginpress' ) );
54 return $errors;
55 endif;
56 return $errors;
57 }
58
59
60 /**
61 * Save privacy policy acceptance.
62 *
63 * @since 1.0.19
64 * @param int $user_id The user ID.
65 * @return void
66 */
67 function loginpress_privacy_policy_save( $user_id ) {
68 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- This is called during user registration process where nonce is already verified.
69 if ( isset( $_POST['lp_privacy_policy'] ) ) {
70 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- This is called during user registration process where nonce is already verified.
71 update_user_meta( $user_id, 'lp_privacy_policy', sanitize_text_field( wp_unslash( $_POST['lp_privacy_policy'] ) ) );
72 }
73 }
74