[wp-trac] [WordPress Trac] #47509: add a filter in wp_user_personal_data_exporter() to make it easier to include additional user meta in a personal data export
WordPress Trac
noreply at wordpress.org
Tue Jan 21 22:14:47 UTC 2020
#47509: add a filter in wp_user_personal_data_exporter() to make it easier to
include additional user meta in a personal data export
---------------------------------------------------+-----------------------
Reporter: pbiron | Owner: xkon
Type: enhancement | Status: assigned
Priority: normal | Milestone: 5.4
Component: Privacy | Version:
Severity: normal | Resolution:
Keywords: has-patch 2nd-opinion has-screenshots | Focuses:
---------------------------------------------------+-----------------------
Comment (by pbiron):
Replying to [comment:7 xkon]:
> I'm on the same side I've tried "forcing" to not allow any duplicate
names, but unfortunately, there's no way of throwing a notice to the devs
and stripping them out or any other way that I could think of would
produce wrong results, so still, not a good way and I preferred to leave
everything as-is.
Stripping out the duplicates is not hard. There might be more "elegant"
ways, but the following works just fine:
{{{
<?php
$reserved_names = wp_list_pluck( $user_data_to_export, 'name' );
$extra_data = apply_filters( 'wp_privacy_additional_user_data',
array(), $user_data_to_export );
#extra_data = array_filter(
$extra_data,
function( $item ) use ( $reserved_names ) {
return ! in_array( $item['name'], $reserved_names );
}
);
}}}
> This is the reason actually that I added the extra param of
`$user_default_data` at least this way anyone interested can
programmatically check it as well (I know that exporting over and over
again is tedious work :D) to avoid duplicate titles.
I figured that's why you passed that parameter to the filter...it's what
gave me the idea to see what happened if I returned duplicates :-)
With that in mind, it might be a good idea to add something to the
DocBlock for the filter that tells plugin authors they should not return
items with any of the names from `$user_data_to_export`. And
specifically, that any such items will **not** change what is exported by
core and that the duplicates may confuse users.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47509#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list