Skip to content
Docs
Get RestroPress

Filter

rpress_update_discount_meta_{$key}

Updated
On this page

Filters a discount meta value before it is saved.

Runs in RPRESS_Discount::update_meta() before update_post_meta(). The key used in the hook name is the full meta key, which already includes the _rpress_discount_ prefix, so the hook for the code is rpress_update_discount_meta__rpress_discount_code.

Parameters#

ParameterTypeDescription
$valuemixedThe meta value to be saved.
$discount_idintThe discount ID.

Return value#

mixed. The meta value to save.

Example#

function my_update_discount_code_meta( $value, $discount_id ) {
	return strtoupper( $value );
}
add_filter( 'rpress_update_discount_meta__rpress_discount_code', 'my_update_discount_code_meta', 10, 2 );

Notes#

Note the doubled underscore in the resolved hook name: {$key} is '_rpress_discount_' followed by the field name, for example _rpress_discount_code.

Source#

Applied in:

  • includes/class-rpress-discount.php (line 666), in RPRESS_Discount::update_meta()
Was this page helpful?