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

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


Description Description

Used most frequently when editing a forum/topic/reply


Parameters Parameters

$field

(Optional) Name of the key

Default value: 'ID'

$context

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

Default value: 'edit'


Top ↑

Return Return

(string) Field value


Top ↑

Source Source

File: includes/common/functions.php

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

	// Get the post, and maybe get a field from it
	$post   = get_post();
	$retval = isset( $post->{$field} )
		? sanitize_post_field( $field, $post->{$field}, $post->ID, $context )
		: '';

	// Filter & return
	return apply_filters( 'bbp_get_global_post_field', $retval, $post, $field, $context );
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.1.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.