Skip to content
Docs
Get RestroPress

Filter

rpress_metabox_fields_save

Updated
On this page

Filters the list of post meta keys saved from the menu item editor.

Runs when the save handler collects the field names to read from the submitted form. Every key in the list is read from the request and written with update_post_meta(); a key that is missing or empty in the request has its meta deleted. Add the name of any custom form field you want saved automatically.

Parameters#

ParameterTypeDescription
$fieldsarrayArray of meta key strings to save.

Return value#

array. The array of meta keys to save.

Example#

function my_save_prep_time_field( $fields ) {
	$fields[] = 'my_prep_time';
	return $fields;
}
add_filter( 'rpress_metabox_fields_save', 'my_save_prep_time_field' );

Notes#

Called from two save paths with different default lists: RP_FoodItem_Meta_Boxes::metabox_fields() (the active editor) and rpress_fooditem_metabox_fields() (legacy handler). Values are sanitized with sanitize_text_field(), or rpress_sanitize_array() for arrays, before saving.

Source#

Applied in:

  • includes/admin/fooditems/class-rp-fooditem-metaboxes.php (line 183), in RP_FoodItem_Meta_Boxes::metabox_fields()
  • includes/admin/fooditems/metabox.php (line 41), in rpress_fooditem_metabox_fields()

See also#

Was this page helpful?