Action uncanny-learndash-groups

ulgm_groups_key_redemption_form_end

Fires at the end of the group key redemption form, allowing for custom additions or modifications.

add_action( 'ulgm_groups_key_redemption_form_end', $callback, 10, 1 );

Description

Fires at the end of the user key redemption form. Developers can use this action to add custom elements or logic after the form's primary fields but before the form submission. This hook is ideal for post-form UI enhancements or actions that depend on the form's structure being complete.


Usage

add_action( 'ulgm_groups_key_redemption_form_end', 'your_function_name', 10, 1 );

Examples

<?php
/**
 * Example: Add a custom success message after the group key redemption form.
 *
 * This hook fires after the group key redemption form has been fully rendered.
 * We can use this to display a confirmation message or additional instructions.
 */
add_action( 'ulgm_groups_key_redemption_form_end', 'my_custom_group_key_redemption_message', 10 );

if ( ! function_exists( 'my_custom_group_key_redemption_message' ) ) {
	/**
	 * Displays a custom message after the group key redemption form.
	 *
	 * The function is designed to be called by the 'ulgm_groups_key_redemption_form_end' action.
	 * No parameters are accepted by this specific action hook in its current implementation,
	 * so we define it without parameters, but explicitly set accepted_args to 0 for clarity.
	 */
	function my_custom_group_key_redemption_message() {
		// In a real-world scenario, you might want to check if the form was successfully submitted
		// or if there are specific conditions to display this message.
		// For this example, we'll just display a simple message.

		echo '<div class="ulgm-redemption-success-message" style="margin-top: 20px; padding: 15px; background-color: #e8f5e9; border: 1px solid #c8e6c9; color: #388e3c; border-radius: 4px;">';
		echo '<strong>Success!</strong> Your group key has been processed. You should now have access to the group content.';
		echo '</div>';
	}
}
?>

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/includes/forms/user-code-redemption.php:59

?>"/>
						<input type="hidden" name="key"
							   value="<?php echo crypt( get_the_ID(), 'uncanny-learndash-groups' ); ?>"/>
					</td>
				</tr>
				<?php do_action( 'ulgm_groups_key_redemption_form_after_enrollment_key' ); ?>
			</table>
			<?php do_action( 'ulgm_groups_key_redemption_form_end' ); ?>
		</fieldset>
	</form>
<?php


Scroll to Top