BP_Group_Export::process_data( $user, $page, bool $email_address = false )
Export member created groups.
Description
Parameters
- $user
-
(Required)
- $page
-
(Required)
- $email_address
-
(Optional)
Default value: false
Return
(array)
Source
File: bp-core/gdpr/class-bp-group-export.php
function process_data( $user, $page, $email_address = false ) { if ( ! $user || is_wp_error( $user ) ) { return $this->response( array(), true ); } $export_items = array(); $data_items = $this->get_data( $user, $page ); foreach ( $data_items['items'] as $item ) { $group_id = "bp_groups"; $group_label = __( "Groups", 'buddyboss' ); $item_id = "{$this->exporter_name}-{$group_id}-{$item->id}"; $avatar = false; $cover_photo = false; if ( function_exists( 'bp_core_fetch_avatar' ) ) { $avatar = bp_core_fetch_avatar( array( 'item_id' => $item->id, 'object' => 'group', 'type' => 'full', 'html' => false, ) ); } if ( function_exists( 'bp_attachments_get_attachment' ) ) { $cover_photo = bp_attachments_get_attachment( 'url', array( 'item_id' => $item->id, 'type' => 'cover-image', 'object_dir' => 'groups', ) ); } if ( empty( $avatar ) || ! $avatar ) { $avatar = __( 'N/A', 'buddyboss' ); } if ( empty( $cover_photo ) || ! $cover_photo ) { $cover_photo = __( 'N/A', 'buddyboss' ); } $group_permalink = bp_get_group_permalink( $item ); $data = array( array( 'name' => __( 'Group Name', 'buddyboss' ), 'value' => $item->name, ), array( 'name' => __( 'Group Description', 'buddyboss' ), 'value' => $item->description, ), array( 'name' => __( 'Group slug', 'buddyboss' ), 'value' => $item->slug, ), array( 'name' => __( 'Created Date (GMT)', 'buddyboss' ), 'value' => $item->date_created, ), array( 'name' => __( 'Group Status', 'buddyboss' ), 'value' => ucfirst( $item->status ), ), array( 'name' => __( 'Group Avatar', 'buddyboss' ), 'value' => $avatar, ), array( 'name' => __( 'Group Cover Photo', 'buddyboss' ), 'value' => $cover_photo, ), array( 'name' => __( 'Group URL', 'buddyboss' ), 'value' => $group_permalink, ), ); $metas2export = array(); $metas2export['total_member_count'] = __( 'Total Members', 'buddyboss' ); $metas2export['last_activity'] = __( 'ast Activity', 'buddyboss' ); /** * Filter allow to add additional metas without issues. */ $metas2export = apply_filters( 'buddyboss_bp_gdpr_group_export_metas', $metas2export, $data_items ); /** * Process the metas. */ foreach ( $item->metas as $meta ) { if ( isset( $metas2export[ $meta->meta_key ] ) ) { $value = $this->easy_readable( $meta->meta_value ); // converting it to user friendly. $value = apply_filters( 'buddyboss_bp_gdpr_group_meta_value_format', $value, $meta ); $data[] = array( 'name' => $metas2export[ $meta->meta_key ], 'value' => $value, ); } } $data = apply_filters( 'buddyboss_bp_gdpr_group_after_data_prepare', $data, $item, $data_items ); $export_items[] = array( 'group_id' => $group_id, 'group_label' => $group_label, 'item_id' => $item_id, 'data' => $data, ); } $done = $data_items['total'] < $data_items['offset']; return $this->response( $export_items, $done ); }
Changelog
Version | Description |
---|---|
BuddyBoss 1.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.