Changeset 6647 for trunk/bp-xprofile/bp-xprofile-filters.php
- Timestamp:
- 12/17/2012 05:55:30 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-xprofile/bp-xprofile-filters.php
r6646 r6647 192 192 } 193 193 194 /** 195 * Ensures that BP data appears in comments array 196 * 197 * This filter loops through the comments return by a normal WordPress request 198 * and swaps out user data with BP xprofile data, where available 199 * 200 * @param array $comments 201 * @param int $post_id 202 * @return array $comments 203 */ 194 204 function xprofile_filter_comments( $comments, $post_id ) { 205 // Locate comment authors with WP accounts 195 206 foreach( (array) $comments as $comment ) { 196 207 if ( $comment->user_id ) { … … 199 210 } 200 211 201 if ( empty( $user_ids ) ) 212 // If none are found, just return the comments array 213 if ( empty( $user_ids ) ) { 202 214 return $comments; 203 215 } 216 217 // Pull up the xprofile fullname of each commenter 204 218 if ( $fullnames = BP_XProfile_ProfileData::get_value_byid( 1, $user_ids ) ) { 205 219 foreach( (array) $fullnames as $user ) { 206 $users[$user->user_id] = trim( stripslashes( $user->value ) ); 207 } 208 } 209 220 $users[ $user->user_id ] = trim( stripslashes( $user->value ) ); 221 } 222 } 223 224 // Loop through and match xprofile fullname with commenters 210 225 foreach( (array) $comments as $i => $comment ) { 211 if ( ! empty( $comment->user_id ) ) {212 if ( ! empty( $users[$comment->user_id] ) ) {213 $comments[ $i]->comment_author = $users[$comment->user_id];226 if ( ! empty( $comment->user_id ) ) { 227 if ( ! empty( $users[ $comment->user_id ] ) ) { 228 $comments[ $i ]->comment_author = $users[ $comment->user_id ]; 214 229 } 215 230 }
Note: See TracChangeset
for help on using the changeset viewer.