BP_Group_Membership_Export::process_data( $user, $page, bool $email_address = false )
Export member group memberships.
Description
Parameters
- $user
-
(Required)
- $page
-
(Required)
- $email_address
-
(Optional)
Default value: false
Return
(array)
Source
File: bp-core/gdpr/class-bp-group-membership-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 = groups_get_group( $item->group_id ); $group_id = 'bp_group_membership'; $group_label = __( 'Group Membership', 'buddyboss' ); $item_id = "{$this->exporter_name}-{$group_id}-{$item->id}"; $group_permalink = bp_get_group_permalink( $group ); $membership_type = false; if ( $item->user_id === $user->ID && '0' === $item->is_confirmed && '0' === $item->inviter_id ) { $group_label = __( 'Group Pending Requests', "buddyboss" ); $membership_type = 'pending_request'; } elseif ( $item->user_id === $user->ID && '0' === $item->is_confirmed && '0' === $item->inviter_id ) { $group_label = __( 'Group Pending Received Invitation Requests', 'buddyboss' ); $membership_type = 'pending_received_invitation'; } elseif ( $item->inviter_id === $user->ID && '0' === $item->is_confirmed ) { $group_label = __( 'Group Pending Sent Invitation Requests', 'buddyboss' ); $membership_type = 'pending_sent_invitation'; } elseif ( $item->user_id === $user->ID && '1' === $item->is_confirmed ) { $group_label = __( 'Group Membership', 'buddyboss' ); $membership_type = 'membership'; } $group_id .= "_{$membership_type}"; // force to create separate group for each type. $data = array( array( 'name' => __( 'Group Name', 'buddyboss' ), 'value' => bp_get_group_name( $group ), ), array( 'name' => __( 'Sent Date (GMT)', 'buddyboss' ), 'value' => $item->date_modified, ), array( 'name' => __( 'Group URL', 'buddyboss' ), 'value' => $group_permalink, ), ); if ( 'pending_received_invitation' === $membership_type ) { $get_user = get_userdata( $item->inviter_id ); $data[] = array( 'name' => __( 'Sent by', 'buddyboss' ), 'value' => $get_user->display_name, ); } if ( 'pending_sent_invitation' === $membership_type ) { $get_user = get_userdata( $item->user_id ); $data[] = array( 'name' => __( 'Sent to', 'buddyboss' ), 'value' => $get_user->display_name, ); } if ( ! empty( $item->comments ) ) { $data[] = array( 'name' => __( 'Group Comments', 'buddyboss' ), 'value' => $item->comments, ); } $data = apply_filters( 'buddyboss_bp_gdpr_group_membership_after_data_prepare', $data, $item, $data_items, $membership_type ); $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.