BP_Bbp_Gdpr_Replies::replies_exporter( $email_address, int $page = 1 )

Export member created forum replies.

Description

Parameters

$email_address

(Required)

$page

(Optional)

Default value: 1

Return

(array)

Source

File: bp-core/gdpr/class-bp-bbp-gdpr-replies.php

74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
function replies_exporter( $email_address, $page = 1 ) {
    $per_page = 500; // Limit us to avoid timing out
    $page     = (int) $page;
 
    $export_items = array();
 
    $user = get_user_by( 'email', $email_address );
    if ( false === $user ) {
        return array(
            'data' => $export_items,
            'done' => true,
        );
    }
 
    $replies_details = $this->get_replies( $user, $page, $per_page );
    $total           = isset( $replies_details['total'] ) ? $replies_details['total'] : 0;
    $replies         = isset( $replies_details['replies'] ) ? $replies_details['replies'] : array();
 
    if ( $total > 0 ) {
        foreach ( $replies as $reply ) {
            $item_id = "bbp-reply-{$reply->ID}";
 
            $group_id = 'bbp-replies';
 
            $group_label = __( 'Discussion Replies', 'buddyboss' );
 
            $permalink = get_permalink( $reply->ID );
 
            $parent_title = get_the_title( $reply->post_parent );
 
            // Plugins can add as many items in the item data array as they want
            $data = array(
                array(
                    'name'  => __( 'Reply Author', 'buddyboss' ),
                    'value' => $user->display_name,
                ),
                array(
                    'name'  => __( 'Reply Author Email', 'buddyboss' ),
                    'value' => $user->user_email,
                ),
                array(
                    'name'  => __( 'Reply Title', 'buddyboss' ),
                    'value' => ! empty( $parent_title ) ? __( 'Reply To: ',
                            'buddyboss' ) . html_entity_decode( $parent_title ) : '',
                ),
                array(
                    'name'  => __( 'Reply Content', 'buddyboss' ),
                    'value' => $reply->post_content,
                ),
                array(
                    'name'  => __( 'Reply Date', 'buddyboss' ),
                    'value' => $reply->post_date,
                ),
                array(
                    'name'  => __( 'Reply URL', 'buddyboss' ),
                    'value' => $permalink,
                ),
            );
 
            $export_items[] = array(
                'group_id'    => $group_id,
                'group_label' => $group_label,
                'item_id'     => $item_id,
                'data'        => $data,
            );
        }
    }
 
    $offset = ( $page - 1 ) * $per_page;
 
    // Tell core if we have more comments to work on still
    $done = $total < $offset;
 
    return array(
        'data' => $export_items,
        'done' => $done,
    );
}

Changelog

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.