Skip to content
Docs
Get RestroPress

Action

rpress_save_fooditem

Updated
On this page

Fires after a menu item's editor fields have been saved.

Runs at the end of the menu item save routine, once the standard meta fields (and, in the active editor, the add-on data) have been written. Use it to save your own custom fields from the submitted form.

Parameters#

ParameterTypeDescription
$post_idintThe ID of the menu item being saved.
$postWP_PostThe menu item post object.

Example#

function my_save_prep_time( $post_id, $post ) {
	if ( isset( $_POST['my_prep_time'] ) ) {
		update_post_meta( $post_id, 'my_prep_time', absint( $_POST['my_prep_time'] ) );
	} else {
		delete_post_meta( $post_id, 'my_prep_time' );
	}
}
add_action( 'rpress_save_fooditem', 'my_save_prep_time', 10, 2 );

Notes#

Fired from both RP_FoodItem_Meta_Boxes::save_meta_boxes() and the legacy rpress_fooditem_meta_box_save() handler; each only runs after its own nonce check, so fields you add must be in the same form submission. Sanitize your own input.

Source#

Fired from:

  • includes/admin/fooditems/class-rp-fooditem-metaboxes.php (line 313), in RP_FoodItem_Meta_Boxes::save_meta_boxes()
  • includes/admin/fooditems/metabox.php (line 95), in rpress_fooditem_meta_box_save()

See also#

Was this page helpful?