Filter the results of the discount code check. This can be used to add additional programmatic requirements to a discount code being used. Return true if discount code is okay to use. Return false or a string containing the error text if the discount code is not okay to use.

apply_filters( 'pmpro_check_discount_code', bool $okay, object $dbcode, int $level_id, string $code );

Parameters

$okay
bool; True if discount code check is okay. False is there was an error.
$dbcode
Object; containing code data from database row.
$level_id
int; Level the user is checking out for.
$code
string; Discount code string.

Source

File: https://github.com/strangerstudios/paid-memberships-pro/blob/master/includes/functions.php

View in Source Code

Related Articles and Recipes

Restrict Discount Code Usage to One Time Per User By Kimberly Coleman


About Actions and Filters in PMPro

Hooks allow you to extend Paid Memberships Pro without editing any core plugin files. You can use a hook to program custom code that interacts with or modifies code in our plugin, Add Ons, your theme, and even WordPress itself.

There are two kinds of hooks: actions and filters.

  • Action hooks allow you to run new custom code at pre-defined locations.
  • Filter hooks allow you to change or extend existing code by modifying the data and returning it back to the software.

Click here to browse the full database of action and filter hooks available in Paid Memberships Pro. For help extending our Add Ons, refer to the individual Add On's documentation page for a list of available hooks.

For more developer-focused information about Paid Memberships Pro, check out the advanced developer topics documentation.

Was this article helpful?
YesNo