Changeset 9342
- Timestamp:
- 12/13/2019 07:43:25 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/buddypress.org/public_html/wp-content/plugins/bbpress-org/tools.php
r1027 r9342 11 11 12 12 // Bail if not capable 13 if ( ! current_user_can( 'moderate' ) ) 13 if ( ! current_user_can( 'moderate' ) ) { 14 14 return; 15 } 15 16 16 17 // Bail if not viewing a user 17 if ( ! bbp_is_single_user() ) 18 if ( ! bbp_is_single_user() ) { 18 19 return; 20 } 19 21 20 22 // Bail if no refresh 21 if ( empty( $_GET['spammer'] ) || ( 'true' != $_GET['spammer'] ) ) 23 if ( empty( $_GET['spammer'] ) || ( 'true' != $_GET['spammer'] ) ) { 22 24 return; 25 } 23 26 24 27 // Get the user ID 25 28 $user_id = bbp_get_displayed_user_id(); 26 29 27 // Bail if empty and protect super admins28 if ( empty( $user_id ) || is_super_admin( $user_id ) )30 // Bail if empty, and protect keymasters 31 if ( empty( $user_id ) || bbp_is_user_keymaster( $user_id ) ) { 29 32 return; 33 } 30 34 31 35 global $wpdb; … … 34 38 $post_types = array( bbp_get_topic_post_type(), bbp_get_reply_post_type() ); 35 39 $post_types = "'" . implode( "', '", $post_types ) . "'"; 36 $status = array( bbp_get_public_status_id(), bbp_get_pending_status_id() ); 40 41 // Make array of post statuses to mark as spam 42 $status = array( bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_pending_status_id() ); 43 $status = "'" . implode( "', '", $status ) . "'"; 37 44 38 45 // Loop through blogs and remove their posts 39 46 // Get topics and replies 40 $posts = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_author = {$user_id} AND post_status = '{$status}'AND post_type IN ({$post_types})" );47 $posts = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_author = {$user_id} AND post_status IN ( '{$status}' ) AND post_type IN ({$post_types})" ); 41 48 42 49 // Loop through posts and spam them 43 if ( ! empty( $posts ) ) {50 if ( ! empty( $posts ) ) { 44 51 foreach ( $posts as $post_id ) { 45 52 … … 58 65 } 59 66 60 // Delete the users description from their profile 61 $user_description = get_user_meta( $user_id, 'description'); 62 if ( !empty( $user_description ) ) { 63 delete_user_meta( $user_id, 'description' ); 64 } 67 // Delete user options 68 bbp_delete_user_options( $user_id ); 69 70 // Remove their name & descriptive info 71 wp_update_user( array( 72 'ID' => $user_id, 73 'description' => '', 74 'first_name' => '', 75 'last_name' => '', 76 'display_name' => '', 77 'user_url' => '' 78 ) ); 65 79 66 80 // Block the user … … 68 82 69 83 // Redirect without _GET 70 wp_safe_redirect( bbp_get_user_profile_url( $user_id ) ); 71 die; 84 bbp_redirect( bbp_get_user_profile_url( $user_id ) ); 72 85 } 73 86 add_action( 'bbp_template_redirect', 'bbporg_make_user_spammer' );
Note: See TracChangeset
for help on using the changeset viewer.