bbp_validate_reply_to

Validate a `reply_to` field for hierarchical replies.

Description

(int) bbp_validate_reply_to( (int) $reply_to = 0, (int) $reply_id = 0 ); 

Checks for 2 scenarios: -- The reply to ID is actually a reply -- The reply to ID does not match the current reply

Returns (int)

$reply_to

Parameters (2)

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

Usage

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

Defined (1)

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

/includes/replies/functions.php  
  1. function bbp_validate_reply_to( $reply_to = 0, $reply_id = 0 ) { 
  2.  
  3. // The parent reply must actually be a reply 
  4. if ( ! bbp_is_reply( $reply_to ) ) { 
  5. $reply_to = 0; 
  6.  
  7. // The parent reply cannot be itself 
  8. if ( $reply_id === $reply_to ) { 
  9. $reply_to = 0; 
  10.  
  11. return (int) $reply_to;