bbp_get_reply

Gets a reply.

Description

bbp_get_reply( (int|object) $reply, (constant) $output = OBJECT, (string) $filter = 'raw' ); 

Parameters (3)

0. $reply (int|object)
Reply id or reply object
1. $output — Optional. (constant) => OBJECT
OBJECT, ARRAY_A, or ARRAY_N. Default = OBJECT
2. $filter — Optional. (string) => 'raw'
The filter.

Options

    ;        


    Usage

    1. if ( !function_exists( 'bbp_get_reply' ) ) { 
    2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/replies/template.php'; 
    3.  
    4. // reply id or reply object 
    5. $reply = null; 
    6.  
    7. // Optional. OBJECT, ARRAY_A, or ARRAY_N. Default = OBJECT 
    8. $output = OBJECT; 
    9.  
    10. // The filter. 
    11. $filter = 'raw'; 
    12.  
    13. // NOTICE! Understand what this does before running. 
    14. $result = bbp_get_reply($reply, $output, $filter); 
    15.  

    Defined (1)

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

    /includes/replies/template.php  
    1. function bbp_get_reply( $reply, $output = OBJECT, $filter = 'raw' ) { 
    2. if ( empty( $reply ) || is_numeric( $reply ) ) 
    3. $reply = bbp_get_reply_id( $reply ); 
    4.  
    5. $reply = get_post( $reply, OBJECT, $filter ); 
    6. if ( empty( $reply ) ) 
    7. return $reply; 
    8.  
    9. if ( $reply->post_type !== bbp_get_reply_post_type() ) 
    10. return null; 
    11.  
    12. if ( $output === OBJECT ) { 
    13. return $reply; 
    14.  
    15. } elseif ( $output === ARRAY_A ) { 
    16. $_reply = get_object_vars( $reply ); 
    17. return $_reply; 
    18.  
    19. } elseif ( $output === ARRAY_N ) { 
    20. $_reply = array_values( get_object_vars( $reply ) ); 
    21. return $_reply; 
    22.  
    23.  
    24. return apply_filters( 'bbp_get_reply', $reply, $output, $filter );