Uncanny Codes: Form integrations and redemption updates

It’s time for a big update to Uncanny Codes, our popular platform for generating, tracking and redeeming codes that can do almost anything in WordPress. It’s been some a longer than usual time since our last update, so in today’s release, we’re adding a lot of really important features that will transform how it’s used on many WordPress sites.

New form integrations

Use Fluent Forms or Forminator?

You’re in luck, the Uncanny Codes 4.1 release adds new integrations both popular form builders. Here’s what the field looks like in Fluent Forms:

Uncanny Codes Fluent Forms Integration

 

And here it is in Forminator:

Uncanny Codes Forminator Integration

It works just like our current integrations with Gravity Forms, WPForms and Formidable. Add the field to a form and code redemption will be processed on form submission. You can use the new fields on everything from single-field redemption forms for logged in users to registration pages that require users to enter a valid code in order to register on a website.

Allow users to redeem the same code multiple times

This is a big new feature, one that we know caused some user frustration in our previous versions.

Up until now, Uncanny Codes would only let a single user redeem a code once, even if the code was set up to allow multiple redemptions. Originally we believe this was a good rule to have in place, as it prevented accidental redemptions by the same person and made codes a lot easier to manage.

Our customers pointed out, however, that this limitation didn’t always make sense. Maybe users repeated a course or needed to unlock something more than once, so instead of them having to juggle multiple codes and figure out what’s been used and what hasn’t, they get one code. When they’re ready to repeat whatever action the user performs (e.g. reset course progress to take it again, create a new job listing, add seats to a group), the user can just keep using the same code. In those situations, where the might be multiple iterations over time of the same action, multiple redemptions of the same code make a lot of sense.

As there is some complexity here, this new feature is managed by batch and it’s not managed in the UI; it does require a snippet of code.

Need more granular control or prefer to manage it at the code level? Here’s what you can leverage instead:

/**
 * Allow multiple code redemptions per user
 */
add_filter(
	'ulc_codes_multiple_redemption_allowed',
	function ( $allowed, $codes_batch_id ) {
		/**
		 * Only allow a certain number of times for certain batches.
		 * Remove this "if" statement block to apply it globally.
		 */
		if ( 123 === $codes_batch_id ) {
			$allowed = true; // use true or false
		}

		return $allowed;
	},
	99,
	2
);
/**
 * Number of times a code is allowed to be reused
 */
add_filter(
	'ulc_codes_times_user_allowed_to_redeem',
	function ( $times, $codes_batch_id ) {
		/**
		 * Only allow a number of times for certain batches.
		 * Remove this "if" statement block to apply it globally.
		 */
		if ( 123 === $codes_batch_id ) {
			$times = 3; // any number can be used here
		}

		return $times;
	},
	99,
	2
);

The code examples above allow site owners to control whether or not code reuse by the same person is allowed, by code batch or globally, and if allowed, how many times a code in each batch can be reused by the same person.

Override redemption limits

When we originally introduced a way to sell codes generated by our plugin with WooCommerce, we intentionally built it to be simple and easy for purchasers to manage codes. We restricted purchased codes to a single use each, as that made it easier for purchasers to track redemptions and distribute codes. Based on customer feedback, however, sometimes some flexibility around the number of allowed redemptions is needed. With that in mind, today’s release allows an override for code redemption limits.

This update leverages a new filter for maximum flexibility, so here’s a sample of how to use it:

add_filter(
	'ulc_code_max_usage',
	function ( $max_usage, $type, $codes_group_id ) {
		// filter by a specific code batch,
		// or comment the restriction out for all batches
		// Automator type max usage
		// of 5 per code:
		if ( 10 === (int) $codes_group_id ) {
			return 5;
		}

		return $max_usage; // change to any number
	},
	99,
	3
);

With that snippet in place, you can unlock additional redemptions that would otherwise be allowed for the batch. We even change the output in the UI to make overrides and override values more obvious:

 

That’s it for new features in the Uncanny Codes 4.1 release, though there are also a few fixes and improved PHP 8.1 compatibility.

2 replies

Comments/Questions

Please note that this is not an official support channel and questions/comments may go unanswered.
To request support, log in to your account and click Submit a Request.

Leave a Reply

Your email address will not be published.