ulgm_groups_key_redemption_form_after_enrollment_key
Fires after a user successfully enrolls using a redemption key, allowing for post-enrollment actions.
add_action( 'ulgm_groups_key_redemption_form_after_enrollment_key', $callback, 10, 1 );
Description
Fires after a user has successfully enrolled using a group enrollment key. Developers can use this hook to perform actions immediately following a successful key redemption, such as sending custom notifications or updating user meta. It provides a reliable point for post-enrollment logic.
Usage
add_action( 'ulgm_groups_key_redemption_form_after_enrollment_key', 'your_function_name', 10, 1 );
Examples
// Add a custom field or message below the enrollment key input on the group code redemption form.
add_action( 'ulgm_groups_key_redemption_form_after_enrollment_key', 'my_custom_redemption_form_field', 10, 0 );
/**
* Adds a custom message to the group code redemption form.
* This is a basic example to demonstrate hooking into the action.
*/
function my_custom_redemption_form_field() {
// You could display a link to instructions, a warning, or additional input fields here.
echo '<p class="ulgm-custom-message" style="font-style: italic; color: grey;">' . esc_html__( 'Please ensure you have the correct enrollment key before submitting.', 'my-text-domain' ) . '</p>';
}
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:38
src/includes/forms/user-code-redemption.php:57
class="required"
value="<?php if ( ulgm_filter_has_var( 'ulgm_code_redeem', INPUT_POST ) ) {
echo ulgm_filter_input( 'ulgm_code_redeem', INPUT_POST );
} ?>"
placeholder="<?php esc_html_e( 'Enrollment key', 'uncanny-learndash-groups' ); ?>"
type="text"/></td>
</tr>
<?php do_action( 'ulgm_groups_key_redemption_form_after_enrollment_key' ); ?>
<?php do_action( 'ulgm_groups_key_redemption_form_before_buttons' ); ?>
<tr>
<td class="label"></td>
<td class="input">
<input type="submit" class="btn btn-default"
value="<?php esc_html_e( 'Redeem code', 'uncanny-learndash-groups' ); ?>"/>
<input type="hidden" name="_ulgm_code_nonce"