gform_postimage_caption

Description

The gform_postimage_caption filter is executed when creating the Post Image Caption field and can be used to modify the “Caption” label.

Usage

This would apply the function to all forms.

add_filter( 'gform_postimage_caption', 'your_function_name', 10, 2 );

To target a specific form, append the form id to the hook name. (format: gform_postimage_caption_FORMID)

add_filter( 'gform_postimage_caption_5', 'your_function_name', 10, 2 );

Parameters

ParameterTypeDescription
$labelstringThe label to be filtered.
$form_idintegerThe current form’s id.

Examples

Change the Post Image Caption Label

This example changes the default Post Image Caption label:

add_filter( 'gform_postimage_caption', 'change_postimage_caption', 10, 2 );
function change_postimage_caption( $label, $form_id ) {
	return 'Image Caption';
}

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Source Code

This filter is located in GF_Field_Post_Image::get_field_input() in includes/fields/class-gf-field-post-image.php.