BP_Bbp_Gdpr_Topics::topics_exporter( $email_address, int $page = 1 )
Export member created forum topics.
Description
Parameters
- $email_address
-
(Required)
- $page
-
(Optional)
Default value: 1
Return
(array)
Source
File: bp-core/gdpr/class-bp-bbp-gdpr-topics.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 152 | function topics_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, ); } $topics_details = $this ->get_topics( $user , $page , $per_page ); $total = isset( $topics_details [ 'total' ] ) ? $topics_details [ 'total' ] : 0; $topics = isset( $topics_details [ 'topics' ] ) ? $topics_details [ 'topics' ] : array (); if ( $total > 0 ) { foreach ( $topics as $topic ) { $item_id = "bbp-topic-{$topic->ID}" ; $group_id = 'bbp-topics' ; $group_label = __( 'Forum Discussions' , 'buddyboss' ); $permalink = get_permalink( $topic ->ID ); // Plugins can add as many items in the item data array as they want $data = array ( array ( 'name' => __( 'Discussion Author' , 'buddyboss' ), 'value' => $user ->display_name, ), array ( 'name' => __( 'Discussion Author Email' , 'buddyboss' ), 'value' => $user ->user_email, ), array ( 'name' => __( 'Discussion Title' , 'buddyboss' ), 'value' => $topic ->post_title, ), array ( 'name' => __( 'Discussion Content' , 'buddyboss' ), 'value' => $topic ->post_content, ), array ( 'name' => __( 'Discussion Date' , 'buddyboss' ), 'value' => $topic ->post_date, ), array ( 'name' => __( 'Discussion URL' , 'buddyboss' ), 'value' => $permalink , ), array ( 'name' => __( 'Discussion Name' , 'buddyboss' ), 'value' => get_the_title( $topic ->post_parent ), ), ); $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
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.