Restrict Content Pro
rcp_update_discount()
Coming soon: Restrict Content Pro is becoming Kadence Memberships. You may see both names used while we update the product, documentation, and customer experience.
Note: This content is provided as a resource within our developer documentation. Because custom code requires highly specific implementation, we encourage you to work with a qualified developer if you need guidance. You can find our recommended consultants here: https://codeable.io/developers/restrict-content-pro
Updates an existing discount by ID. Only pass fields you want to change.
If code is updated, it is stored in lowercase. membership_level_ids is serialized before save.
Actions: rcp_pre_edit_discount, rcp_edit_discount (after update).
Parameters
$discount_id (int) – Discount ID.
$args (array) – Fields to update (same keys as rcp_add_discount(), partial updates OK).
Return values
(true|WP_Error) – true on success; WP_Error for invalid ID, invalid amount, or failed update.
Examples
$result = rcp_update_discount(
$discount_id,
array(
'status' => 'active',
'max_uses' => 100,
)
);
if ( is_wp_error( $result ) ) {
// Handle error.
}