' . sprintf( __( 'Your email address has not been updated yet. Please check your inbox at %s for a confirmation email.' ), '' . esc_html( $email['newemail'] ) . '
' ) . '
';
}
}
@@ -2873,8 +2960,10 @@
* Finds and exports personal data associated with an email address from the user and user_meta table.
*
* @since 4.9.6
+ * @since 5.4.0 Added 'Community Events Location' group to the export data.
+ * @since 5.4.0 Added 'Session Tokens' group to the export data.
*
- * @param string $email_address The users email address.
+ * @param string $email_address The user's email address.
* @return array An array of personal data.
*/
function wp_user_personal_data_exporter( $email_address ) {
@@ -2893,7 +2982,7 @@
$user_meta = get_user_meta( $user->ID );
- $user_prop_to_export = array(
+ $user_props_to_export = array(
'ID' => __( 'User ID' ),
'user_login' => __( 'User Login Name' ),
'user_nicename' => __( 'User Nice Name' ),
@@ -2909,7 +2998,7 @@
$user_data_to_export = array();
- foreach ( $user_prop_to_export as $key => $name ) {
+ foreach ( $user_props_to_export as $key => $name ) {
$value = '';
switch ( $key ) {
@@ -2938,13 +3027,127 @@
}
}
+ // Get the list of reserved names.
+ $reserved_names = array_values( $user_props_to_export );
+
+ /**
+ * Filter to extend the user's profile data for the privacy exporter.
+ *
+ * @since 5.4.0
+ *
+ * @param array $additional_user_profile_data {
+ * An array of name-value pairs of additional user data items. Default empty array.
+ *
+ * @type string $name The user-facing name of an item name-value pair,e.g. 'IP Address'.
+ * @type string $value The user-facing value of an item data pair, e.g. '50.60.70.0'.
+ * }
+ * @param WP_User $user The user whose data is being exported.
+ * @param string[] $reserved_names An array of reserved names. Any item in `$additional_user_data`
+ * that uses one of these for its `name` will not be included in the export.
+ */
+ $_extra_data = apply_filters( 'wp_privacy_additional_user_profile_data', array(), $user, $reserved_names );
+
+ if ( is_array( $_extra_data ) && ! empty( $_extra_data ) ) {
+ // Remove items that use reserved names.
+ $extra_data = array_filter(
+ $_extra_data,
+ function( $item ) use ( $reserved_names ) {
+ return ! in_array( $item['name'], $reserved_names, true );
+ }
+ );
+
+ if ( count( $extra_data ) !== count( $_extra_data ) ) {
+ _doing_it_wrong(
+ __FUNCTION__,
+ sprintf(
+ /* translators: %s: wp_privacy_additional_user_profile_data */
+ __( 'Filter %s returned items with reserved names.' ),
+ '' . __( 'Action has been confirmed.' ) . '
';
$message .= '' . __( 'The site administrator has been notified and will fulfill your request as soon as possible.' ) . '
';
@@ -3339,8 +3596,8 @@
$requests_query = new WP_Query(
array(
'post_type' => 'user_request',
- 'post_name__in' => array( $action_name ), // Action name stored in post_name column.
- 'title' => $email_address, // Email address stored in post_title column.
+ 'post_name__in' => array( $action_name ), // Action name stored in post_name column.
+ 'title' => $email_address, // Email address stored in post_title column.
'post_status' => array(
'request-pending',
'request-confirmed',
@@ -3387,7 +3644,7 @@
$description = __( 'Erase Personal Data' );
break;
default:
- /* translators: %s: action name */
+ /* translators: %s: Action name. */
$description = sprintf( __( 'Confirm the "%s" action' ), $action_name );
break;
}
@@ -3415,7 +3672,7 @@
*/
function wp_send_user_request( $request_id ) {
$request_id = absint( $request_id );
- $request = wp_get_user_request_data( $request_id );
+ $request = wp_get_user_request( $request_id );
if ( ! $request ) {
return new WP_Error( 'invalid_request', __( 'Invalid user request.' ) );
@@ -3497,7 +3754,7 @@
$content = str_replace( '###SITENAME###', $email_data['sitename'], $content );
$content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
- /* translators: Confirm privacy data request notification email subject. 1: Site title, 2: Name of the action */
+ /* translators: Confirm privacy data request notification email subject. 1: Site title, 2: Name of the action. */
$subject = sprintf( __( '[%1$s] Confirm Action: %2$s' ), $email_data['sitename'], $email_data['description'] );
/**
@@ -3520,7 +3777,31 @@
*/
$subject = apply_filters( 'user_request_action_email_subject', $subject, $email_data['sitename'], $email_data );
- $email_sent = wp_mail( $email_data['email'], $subject, $content );
+ $headers = '';
+
+ /**
+ * Filters the headers of the email sent when an account action is attempted.
+ *
+ * @since 5.4.0
+ *
+ * @param string|array $headers The email headers.
+ * @param string $subject The email subject.
+ * @param string $content The email content.
+ * @param int $request_id The request ID.
+ * @param array $email_data {
+ * Data relating to the account action email.
+ *
+ * @type WP_User_Request $request User request object.
+ * @type string $email The email address this is being sent to.
+ * @type string $description Description of the action being performed so the user knows what the email is for.
+ * @type string $confirm_url The link to click on to confirm the account action.
+ * @type string $sitename The site name sending the mail.
+ * @type string $siteurl The site URL sending the mail.
+ * }
+ */
+ $headers = apply_filters( 'user_request_action_email_headers', $headers, $subject, $content, $request_id, $email_data );
+
+ $email_sent = wp_mail( $email_data['email'], $subject, $content, $headers );
if ( $switched_locale ) {
restore_previous_locale();
@@ -3571,13 +3852,13 @@
*
* @param string $request_id ID of the request being confirmed.
* @param string $key Provided key to validate.
- * @return bool|WP_Error WP_Error on failure, true on success.
+ * @return bool|WP_Error True on success, WP_Error on failure.
*/
function wp_validate_user_request_key( $request_id, $key ) {
global $wp_hasher;
$request_id = absint( $request_id );
- $request = wp_get_user_request_data( $request_id );
+ $request = wp_get_user_request( $request_id );
if ( ! $request ) {
return new WP_Error( 'invalid_request', __( 'Invalid request.' ) );
@@ -3629,14 +3910,14 @@
}
/**
- * Return data about a user request.
+ * Return the user request object for the specified request ID.
*
* @since 4.9.6
*
- * @param int $request_id Request ID to get data about.
+ * @param int $request_id The ID of the user request.
* @return WP_User_Request|false
*/
-function wp_get_user_request_data( $request_id ) {
+function wp_get_user_request( $request_id ) {
$request_id = absint( $request_id );
$post = get_post( $request_id );
@@ -3646,110 +3927,3 @@
return new WP_User_Request( $post );
}
-
-/**
- * WP_User_Request class.
- *
- * Represents user request data loaded from a WP_Post object.
- *
- * @since 4.9.6
- */
-final class WP_User_Request {
- /**
- * Request ID.
- *
- * @var int
- */
- public $ID = 0;
-
- /**
- * User ID.
- *
- * @var int
- */
- public $user_id = 0;
-
- /**
- * User email.
- *
- * @var int
- */
- public $email = '';
-
- /**
- * Action name.
- *
- * @var string
- */
- public $action_name = '';
-
- /**
- * Current status.
- *
- * @var string
- */
- public $status = '';
-
- /**
- * Timestamp this request was created.
- *
- * @var int|null
- */
- public $created_timestamp = null;
-
- /**
- * Timestamp this request was last modified.
- *
- * @var int|null
- */
- public $modified_timestamp = null;
-
- /**
- * Timestamp this request was confirmed.
- *
- * @var int
- */
- public $confirmed_timestamp = null;
-
- /**
- * Timestamp this request was completed.
- *
- * @var int
- */
- public $completed_timestamp = null;
-
- /**
- * Misc data assigned to this request.
- *
- * @var array
- */
- public $request_data = array();
-
- /**
- * Key used to confirm this request.
- *
- * @var string
- */
- public $confirm_key = '';
-
- /**
- * Constructor.
- *
- * @since 4.9.6
- *
- * @param WP_Post|object $post Post object.
- */
- public function __construct( $post ) {
- $this->ID = $post->ID;
- $this->user_id = $post->post_author;
- $this->email = $post->post_title;
- $this->action_name = $post->post_name;
- $this->status = $post->post_status;
- $this->created_timestamp = strtotime( $post->post_date_gmt );
- $this->modified_timestamp = strtotime( $post->post_modified_gmt );
- $this->confirmed_timestamp = (int) get_post_meta( $post->ID, '_wp_user_request_confirmed_timestamp', true );
- $this->completed_timestamp = (int) get_post_meta( $post->ID, '_wp_user_request_completed_timestamp', true );
- $this->request_data = json_decode( $post->post_content, true );
- $this->confirm_key = $post->post_password;
- }
-}