Skip to content
Docs
Get RestroPress

Action

rpress_edit_discount_form_before_name

Updated
On this page

Fires on the Edit Discount form before the Name row.

Runs while the Edit Discount form is being printed, inside the form table, before the Name row. Output complete table rows (tr elements) so the markup stays valid. The callback receives the discount ID and the loaded discount object, which lets you pre-fill your own fields.

Parameters#

ParameterTypeDescription
$discount_idintThe discount ID being edited.
$discountRPRESS_Discount|falseThe discount object loaded with rpress_get_discount(); false when the discount was not found.

Example#

function my_discount_field_row( $discount_id, $discount ) {
	$note = get_post_meta( $discount_id, '_my_discount_note', true );
	?>
	<tr>
		<th scope="row"><label for="my-discount-note"><?php esc_html_e( 'Internal note', 'my-plugin' ); ?></label></th>
		<td><input type="text" id="my-discount-note" name="my_discount_note" class="regular-text" value="<?php echo esc_attr( $note ); ?>" /></td>
	</tr>
	<?php
}
add_action( 'rpress_edit_discount_form_before_name', 'my_discount_field_row', 10, 2 );

Notes#

Printing a field does not save it. Save submitted values from rpress_post_insert_discount (add) or rpress_post_update_discount (edit).

Source#

Fired from:

  • includes/admin/discounts/edit-discount.php (line 39)

See also#

Was this page helpful?