Functions

Retrieve or display nonce hidden field for forms.

bb_nonce_field(string $action = -1, string $name = "_wpnonce", boolean $referer = true, boolean $echo = true) : string

The nonce field is used to validate that the contents of the form came from the location on the current site and not somewhere else. The nonce does not offer absolute protection, but should protect against most cases. It is very important to use nonce field in forms.

If you set $echo to true and set $referer to true, then you will need to retrieve the wp referer field. If you have the $referer set to true and are echoing the nonce field, it will also echo the referer field.

The $action and $name are optional, but if you want to have better security, it is strongly suggested to set those two parameters. It is easier to just call the function without any parameters, because validation of the nonce doesn't require any parameters, but since crackers know what the default is it won't be difficult for them to find a way around your nonce and cause damage.

The input name will be whatever $name value you gave. The input value will be the nonce creation value.

package bbPress
package bbPress
subpackage Security
since 1.0

Parameters

$action

string

Optional. Action name.

$name

string

Optional. Nonce name.

$referer

boolean

Optional, default true. Whether to set the referer field for validation.

$echo

boolean

Optional, default true. Whether to display or return hidden form field.

Returns

stringNonce field.

Retrieve URL with nonce added to URL query.

bb_nonce_url(string $actionurl, string $action = -1) : string
package bbPress
package bbPress
subpackage Security
since 1.0

Parameters

$actionurl

string

URL to add nonce action

$action

string

Optional. Nonce action name

Returns

stringURL with nonce action added.