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

Get the unfiltered value of a global $post’s key

Description

Used most frequently when editing a forum/topic/reply

Parameters

$field

(Optional) Name of the key

Default value: 'ID'

$context

(Optional) How to sanitize - raw|edit|db|display|attribute|js

Default value: 'edit'

Return

(string) Field value

Source

File: bp-forums/common/functions.php

function bbp_get_global_post_field( $field = 'ID', $context = 'edit' ) {
	global $post;

	$retval = isset( $post->$field ) ? $post->$field : '';
	$retval = sanitize_post_field( $field, $retval, $post->ID, $context );

	return apply_filters( 'bbp_get_global_post_field', $retval, $post );
}

Changelog

Changelog
Version Description
bbPress (r3694) Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.