ulgm_groups_registration_form_after_password
Fires after the password field on the group registration form has been displayed.
add_action( 'ulgm_groups_registration_form_after_password', $callback, 10, 1 );
Description
Fires after the password field on the Uncanny Groups registration form. Developers can use this hook to add custom fields, validation, or actions specifically after the user enters their password and before the confirmation field appears.
Usage
add_action( 'ulgm_groups_registration_form_after_password', 'your_function_name', 10, 1 );
Examples
// Example: Add a field to require users to agree to terms and conditions after the password field.
function my_groups_registration_terms_field() {
?>
<tr class="terms-and-conditions-row">
<td class="label">
<label for="agree_to_terms"><?php esc_html_e( 'Agree to Terms', 'your-text-domain' ); ?></label>
</td>
<td class="input">
<input type="checkbox" name="agree_to_terms" id="agree_to_terms" value="1" required="required" />
<?php esc_html_e( 'I agree to the', 'your-text-domain' ); ?>
<a href="<?php echo esc_url( home_url( '/terms-and-conditions/' ) ); ?>" target="_blank"><?php esc_html_e( 'Terms and Conditions', 'your-text-domain' ); ?></a>.
</td>
</tr>
<?php
}
add_action( 'ulgm_groups_registration_form_after_password', 'my_groups_registration_terms_field', 10 ); // 10 is the default priority, 1 is the number of arguments accepted by the callback function.
// Example: Add a custom validation for the password after it's been added to the form.
// This function would typically be paired with a hook that runs during form submission validation.
// Since this hook runs after the password field is outputted, a common use case would be to
// add client-side validation via JavaScript, or to mark an element for later server-side validation.
// For demonstration, we'll assume this hook is part of a larger system that handles form submission
// and we want to ensure a specific class is present on the password confirmation field for JS.
// Note: This specific hook is for *outputting* HTML, so direct server-side validation logic
// needs to be attached to a different hook that handles form submission.
function my_groups_registration_password_enhancement( $group_id = null, $user_id = null ) {
// This hook is primarily for adding HTML. To implement actual validation logic,
// you'd typically hook into a form submission hook.
// However, for demonstration, let's imagine we want to add a data attribute
// to the password confirmation field, which a separate JavaScript file would then read.
// This is conceptual, as we don't have direct access to the 'password_again' input here.
// In a real scenario, you might have access to the form object or be able to output
// JavaScript that targets the correct element.
// For the sake of a realistic PHP example for this *output* hook,
// let's consider adding a hidden field or a JavaScript snippet that relates to the password.
// Example: Add a hidden field to track if JavaScript is enabled.
?>
<input type="hidden" name="js_enabled_for_password" value="1" />
<?php
// This is a placeholder. Real validation logic belongs to submission hooks.
// If you needed to *dynamically* add classes or attributes to the password *confirm* field
// based on some logic determined after the password field is rendered, you'd typically
// need access to the form's current state or use JavaScript.
}
add_action( 'ulgm_groups_registration_form_after_password', 'my_groups_registration_password_enhancement', 20, 2 ); // 20 is a different priority, 2 is the number of arguments accepted.
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-registration-form.php:87
required="required"
minlength="6"
class="required"
placeholder="<?php esc_html_e( 'Password', 'uncanny-learndash-groups' ); ?>"
type="password"/></td>
</tr>
<!-- Password __ END -->
<?php do_action( 'ulgm_groups_registration_form_after_password' ); ?>
<?php do_action( 'ulgm_groups_registration_form_before_password_confirm' ); ?>
<!-- Confirm Password __ START -->
<tr>
<td class="label"><label
for="password_again"><?php esc_html_e( 'Confirm Password', 'uncanny-learndash-groups' ); ?></label>
</td>
<td class="input">