Description
The wpforms_coupons_generator_generate_code_args
filters default settings when using the Generate Code button with the Coupons addon.
Parameters
- $default
- (array) (Required) Array of default settings.
Source
wpforms-coupons/src/Generator.php
More Information
The filter is applied to an array of default settings that the Generate Code button uses when automatically generating a coupon code. Using this filter, you can establish a set of defaults that this functionality can use.
Examples
/** * Allow modifying coupon code generator. * * @link https://wpforms.com/developers/wpforms_coupons_generator_generate_code_args/ * * @param array $default { * Array of default settings. * * @type string $prefix Text before the generated coupon code. Default empty string. * @type string $suffix Text after the generated coupon code. Default empty string. * @type string $characters Characters which will be used to generate coupon code. Default 'ABCDEFGHJKMNPQRSTUVWXYZ23456789'. * @type string $code_length Generated string lengths. * } * @return array */ function wpf_coupons_generator_generate_code_args ( $default ) { // Set your defaults below // Default prefix for the coupon $default[ 'prefix' ] = 'WPFORMS-'; // Default suffix for the coupon $default[ 'suffix' ] = '-COUPON'; // Default allowed characters for the coupon $default[ 'characters' ] = 'ABCDEFGHJKMNPQRSTUVWXYZ23456789'; // Default length for the coupon $default[ 'code_length' ] = 20; return $default; } add_filter( 'wpforms_coupons_generator_generate_code_args', 'wpf_coupons_generator_generate_code_args', 10, 1 );
Related
Article Reference: How to Create a Default Prefix for Your Coupons