bbp_get_global_post_field

Get the unfiltered value of a global $post's key.

Description

(string) bbp_get_global_post_field( (string) $field = 'ID', (string) $context = 'edit' ); 

Used most frequently when editing a forum/topic/reply

Returns (string)

Field value

Parameters (2)

0. $field — Optional. (string) => 'ID'
Name of the key
1. $context — Optional. (string) => 'edit'
How to sanitize - raw|edit|db|display|attribute|js

Usage

  1. if ( !function_exists( 'bbp_get_global_post_field' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/common/functions.php'; 
  3.  
  4. // Name of the key 
  5. $field = 'ID'; 
  6.  
  7. // How to sanitize - raw|edit|db|display|attribute|js 
  8. $context = 'edit'; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bbp_get_global_post_field($field, $context); 
  12.  

Defined (1)

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

/includes/common/functions.php  
  1. function bbp_get_global_post_field( $field = 'ID', $context = 'edit' ) { 
  2. global $post; 
  3.  
  4. $retval = isset( $post->$field ) ? $post->$field : ''; 
  5. $retval = sanitize_post_field( $field, $retval, $post->ID, $context ); 
  6.  
  7. return apply_filters( 'bbp_get_global_post_field', $retval, $post );