PluginProbe
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI / 8.0.5
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI v8.0.5
8.0.5 8.0.4 8.0.3 8.0.1 8.0.2 8.0.0 7.9.9.7 7.9.9.6 7.9.9.5 7.9.9.4 7.9.9.3 7.9.9.2 7.9.9.1 7.9.9 7.9.8 7.9.7 7.9.6 7.9.5 7.9.4 7.9.3 7.9.2 7.9.1 7.9.0 7.8.9 7.8.8 All 47 releases
← All changes | includes/privacy/erasers/user-data.php +138 -0 7.9.2 → 8.0.5 View file →
@@ -1,0 +1,138 @@
1 +<?php
2 +/**
3 + * User Data Erasers
4 + *
5 + * @package GamiPress\Privacy\Erasers\User_Data
6 + * @author GamiPress <[email protected]>, Ruben Garcia <[email protected]>
7 + * @since 1.5.0
8 + */
9 +// Exit if accessed directly
10 +if( !defined( 'ABSPATH' ) ) exit;
11 +
12 +/**
13 + * Register eraser for user meta data.
14 + *
15 + * @since 1.5.0
16 + *
17 + * @param array $erasers
18 + *
19 + * @return array
20 + */
21 +function gamipress_privacy_register_user_data_erasers( $erasers ) {
22 +
23 + $erasers[] = array(
24 + 'eraser_friendly_name' => __( 'Gamification Data', 'gamipress' ),
25 + 'callback' => 'gamipress_privacy_user_data_eraser',
26 + );
27 +
28 + return $erasers;
29 +
30 +}
31 +add_filter( 'wp_privacy_personal_data_erasers', 'gamipress_privacy_register_user_data_erasers' );
32 +
33 +/**
34 + * Eraser for user meta data.
35 + *
36 + * @since 1.5.0
37 + *
38 + * @param string $email_address
39 + * @param int $page
40 + *
41 + * @return array
42 + */
43 +function gamipress_privacy_user_data_eraser( $email_address, $page = 1 ) {
44 +
45 + // Setup vars
46 + $points_types = gamipress_get_points_types();
47 + $achievement_types = gamipress_get_achievement_types();
48 + $rank_types = gamipress_get_rank_types();
49 +
50 + $user = get_user_by( 'email', $email_address );
51 + $response = array(
52 + 'items_removed' => true,
53 + 'items_retained' => false,
54 + 'messages' => array(),
55 + 'done' => true
56 + );
57 +
58 + if ( $user && $user->ID ) {
59 +
60 + /* --------------------------
61 + * Points types
62 + -------------------------- */
63 +
64 + // Get all user points types and their hidden meta data
65 + foreach( $points_types as $points_type => $points_type_data ) {
66 +
67 + // User balance
68 + if ( ! gamipress_delete_user_meta( $user->ID, "_gamipress_{$points_type}_points" ) ) {
69 + $response['messages'][] = sprintf( __( 'Your %s balance was unable to be removed at this time.', 'gamipress' ), $points_type_data['plural_name'] );
70 + $response['items_retained'] = true;
71 + }
72 +
73 + // Awarded
74 + if ( ! gamipress_delete_user_meta( $user->ID, "_gamipress_{$points_type}_points_awarded" ) ) {
75 + $response['messages'][] = sprintf( __( 'Your %s awarded was unable to be removed at this time.', 'gamipress' ), $points_type_data['plural_name'] );
76 + $response['items_retained'] = true;
77 + }
78 +
79 + // Deducted
80 + if ( ! gamipress_delete_user_meta( $user->ID, "_gamipress_{$points_type}_points_deducted" ) ) {
81 + $response['messages'][] = sprintf( __( 'Your %s deducted was unable to be removed at this time.', 'gamipress' ), $points_type_data['plural_name'] );
82 + $response['items_retained'] = true;
83 + }
84 +
85 + // Expended
86 + if ( ! gamipress_delete_user_meta( $user->ID, "_gamipress_{$points_type}_points_expended" ) ) {
87 + $response['messages'][] = sprintf( __( 'Your %s expended was unable to be removed at this time.', 'gamipress' ), $points_type_data['plural_name'] );
88 + $response['items_retained'] = true;
89 + }
90 +
91 + /**
92 + * User points balance to erase
93 + *
94 + * @param array $response The response to return to the eraser with keys:
95 + * 'items_removed' => bool,
96 + * 'items_retained' => bool,
97 + * 'messages' => array,
98 + * 'done' => bool
99 + * @param int $user_id The user ID
100 + * @param string $points_type The points type slug
101 + */
102 + $response = apply_filters( "gamipress_privacy_erase_user_points_{$points_type}", $response, $user->ID, $points_type );
103 +
104 + }
105 +
106 + /* --------------------------
107 + * Rank types
108 + -------------------------- */
109 +
110 + // Get all user rank types and their hidden meta data
111 + foreach( $rank_types as $rank_type => $rank_type_data ) {
112 +
113 + if ( ! gamipress_delete_user_meta( $user->ID, "_gamipress_{$rank_type}_rank" ) ) {
114 + $response['messages'][] = sprintf( __( 'Your %s was unable to be removed at this time.', 'gamipress' ), $rank_type_data['singular_name'] );
115 + $response['items_retained'] = true;
116 + }
117 +
118 + /**
119 + * User ranks to erase
120 + *
121 + * @param array $response The response to return to the eraser with keys:
122 + * 'items_removed' => bool,
123 + * 'items_retained' => bool,
124 + * 'messages' => array,
125 + * 'done' => bool
126 + * @param int $user_id The user ID
127 + * @param string $rank_type The rank type slug
128 + */
129 + $response = apply_filters( "gamipress_privacy_erase_user_rank_{$rank_type}", $response, $user->ID, $rank_type );
130 +
131 + }
132 +
133 + }
134 +
135 + // Return our removed items
136 + return $response;
137 +
138 +}