bbp_get_reply( int|object $reply, string $output = OBJECT, string $filter = 'raw' )
Gets a reply
Description Description
Parameters Parameters
- $reply
-
(Required) reply id or reply object
- $output
-
(Optional) OBJECT, ARRAY_A, or ARRAY_N. Default = OBJECT
Default value: OBJECT
- $filter
-
(Optional) Sanitation filter. See sanitize_post()
Default value: 'raw'
Return Return
(mixed) Null if error or reply (in specified form) if success
Source Source
File: includes/replies/template.php
function bbp_get_reply( $reply, $output = OBJECT, $filter = 'raw' ) {
// Maybe get ID from empty or int
if ( empty( $reply ) || is_numeric( $reply ) ) {
$reply = bbp_get_reply_id( $reply );
}
// Bail if no post object
$reply = get_post( $reply, OBJECT, $filter );
if ( empty( $reply ) ) {
return $reply;
}
// Bail if not correct post type
if ( $reply->post_type !== bbp_get_reply_post_type() ) {
return null;
}
// Default return value is OBJECT
$retval = $reply;
// Array A
if ( $output === ARRAY_A ) {
$retval = get_object_vars( $reply );
// Array N
} elseif ( $output === ARRAY_N ) {
$retval = array_values( get_object_vars( $reply ) );
}
// Filter & return
return apply_filters( 'bbp_get_reply', $retval, $reply, $output, $filter );
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.0.0 | Introduced. |