Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/23/2018 01:40:06 AM (7 years ago)
Author:
boonebgorges
Message:

Privacy: Data exporter for XProfile.

See #7817.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-xprofile/bp-xprofile-functions.php

    r11886 r12110  
    13371337    }
    13381338}
     1339
     1340/**
     1341 * Finds and exports personal data associated with an email address from the XProfile tables.
     1342 *
     1343 * @since 4.0.0
     1344 *
     1345 * @param string $email_address  The userss email address.
     1346 * @return array An array of personal data.
     1347 */
     1348function bp_xprofile_personal_data_exporter( $email_address ) {
     1349    $email_address = trim( $email_address );
     1350
     1351    $data_to_export = array();
     1352
     1353    $user = get_user_by( 'email', $email_address );
     1354
     1355    if ( ! $user ) {
     1356        return array(
     1357            'data' => array(),
     1358            'done' => true,
     1359        );
     1360    }
     1361
     1362    $user_data_to_export = array();
     1363
     1364    $user_profile_data = BP_XProfile_ProfileData::get_all_for_user( $user->ID );
     1365    foreach ( $user_profile_data as $field_name => $field ) {
     1366        // Skip non-array fields, which don't belong to XProfile.
     1367        if ( ! is_array( $field ) ) {
     1368            continue;
     1369        }
     1370
     1371        // Re-pull the data so that BuddyPress formats and sanitizes properly.
     1372        $value = xprofile_get_field_data( $field['field_id'], $user->ID, 'comma' );
     1373        $user_data_to_export[] = array(
     1374            'name'  => $field_name,
     1375            'value' => $value,
     1376        );
     1377    }
     1378
     1379    $data_to_export[] = array(
     1380        'group_id'    => 'bp_xprofile',
     1381        'group_label' => __( 'Extended Profile Data', 'buddypress' ),
     1382        'item_id'     => "bp-xprofile-{$user->ID}",
     1383        'data'        => $user_data_to_export,
     1384    );
     1385
     1386    return array(
     1387        'data' => $data_to_export,
     1388        'done' => true,
     1389    );
     1390}
Note: See TracChangeset for help on using the changeset viewer.