Action uncanny-learndash-groups

ulgm_groups_registration_form_start

Fires before the group registration form is displayed, allowing modifications.

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

Description

Fires at the very beginning of the Uncanny Groups user registration form. Developers can use this action to inject custom HTML, fields, or scripts before the form's standard content. It's ideal for adding introductory text, privacy policy links, or consent checkboxes.


Usage

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

Examples

<?php
/**
 * Example function to add a custom field before the first name field in the group registration form.
 *
 * This function demonstrates how to hook into 'ulgm_groups_registration_form_start'
 * to inject custom HTML or logic at the beginning of the Uncanny Groups registration form.
 *
 * @param object $form_handler The instance of the form handler class.
 */
function my_custom_group_registration_field( $form_handler ) {
    // Ensure we only add this field if we're actually displaying the registration form.
    // The $form_handler object might contain context about the current action.
    // Replace 'is_registration_page()' with a more specific check if available in the $form_handler object.
    if ( method_exists( $form_handler, 'is_registration_page' ) && $form_handler->is_registration_page() ) {
        ?>
        <tr>
            <td class="label"><label for="my_custom_field"><?php esc_html_e( 'Your Department', 'my-text-domain' ); ?></label></td>
            <td>
                <input type="text" name="my_custom_field" id="my_custom_field" class="input-text" value="" />
                <p class="description"><?php esc_html_e( 'Please enter your department name.', 'my-text-domain' ); ?></p>
            </td>
        </tr>
        <?php
    }
}
add_action( 'ulgm_groups_registration_form_start', 'my_custom_group_registration_field', 10, 1 );

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:16

</div>
	<?php
	return ob_get_clean();
}
?>
	<form id="ulgm_registration_form" class="uncanny-learndash-groups uo-groups-registration" action="" method="POST">
		<fieldset>
			<?php do_action( 'ulgm_groups_registration_form_start' ); ?>
			<table class="table table-form form-table clr">
				<?php do_action( 'ulgm_groups_registration_form_before_first_name' ); ?>
				<!-- First name  __ START -->
				<tr>
					<td class="label"><label
								for="ulgm_user_first"><?php esc_html_e( 'First name', 'uncanny-learndash-groups' ); ?></label>
					</td>


Scroll to Top