bbp_spam_reply

Marks a reply as spam.

Description

bbp_spam_reply( (int) $reply_id = 0 ); 

Parameters (1)

0. $reply_id — Optional. (int)
The reply id.

Usage

  1. if ( !function_exists( 'bbp_spam_reply' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/replies/functions.php'; 
  3.  
  4. // The reply id. 
  5. $reply_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_spam_reply($reply_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/replies/functions.php  
  1. function bbp_spam_reply( $reply_id = 0 ) { 
  2.  
  3. // Get reply 
  4. $reply = bbp_get_reply( $reply_id ); 
  5. if ( empty( $reply ) ) 
  6. return $reply; 
  7.  
  8. // Bail if already spam 
  9. if ( bbp_get_spam_status_id() === $reply->post_status ) 
  10. return false; 
  11.  
  12. // Execute pre spam code 
  13. do_action( 'bbp_spam_reply', $reply_id ); 
  14.  
  15. // Add the original post status as post meta for future restoration 
  16. add_post_meta( $reply_id, '_bbp_spam_meta_status', $reply->post_status ); 
  17.  
  18. // Set post status to spam 
  19. $reply->post_status = bbp_get_spam_status_id(); 
  20.  
  21. // No revisions 
  22. remove_action( 'pre_post_update', 'wp_save_post_revision' ); 
  23.  
  24. // Update the reply 
  25. $reply_id = wp_update_post( $reply ); 
  26.  
  27. // Execute post spam code 
  28. do_action( 'bbp_spammed_reply', $reply_id ); 
  29.  
  30. // Return reply_id 
  31. return $reply_id;