ulgm_groups_registration_form_after_last_name
Fires after the last name field on the user group registration form, allowing custom content insertion.
add_action( 'ulgm_groups_registration_form_after_last_name', $callback, 10, 1 );
Description
Fires after the last name field is displayed on the Uncanny Groups registration form. Developers can use this hook to add custom fields, messages, or modify the form's layout immediately following the last name input. No parameters are passed.
Usage
add_action( 'ulgm_groups_registration_form_after_last_name', 'your_function_name', 10, 1 );
Examples
add_action( 'ulgm_groups_registration_form_after_last_name', 'my_custom_registration_field_after_last_name', 10 );
/**
* Add a custom field after the last name field in the Uncanny Groups registration form.
*
* This function demonstrates how to hook into 'ulgm_groups_registration_form_after_last_name'
* to add additional fields to the user registration form. In this example, we're adding
* a simple text field for a "Job Title".
*
* @since 1.0.0
*/
function my_custom_registration_field_after_last_name() {
// We assume that the previous field (last name) is within a <tr></table> structure.
// So we'll continue that structure.
?>
<tr>
<td class="label"><label for="ulgm_user_job_title"><?php esc_html_e( 'Job Title', 'uncanny-learndash-groups' ); ?></label></td>
<td class="input">
<input id="ulgm_user_job_title"
name="ulgm_user_job_title"
placeholder="<?php esc_html_e( 'Your Job Title', 'uncanny-learndash-groups' ); ?>"
value="<?php
// Check if the data was submitted via POST and sanitize it
if ( isset( $_POST['ulgm_user_job_title'] ) ) {
echo esc_attr( sanitize_text_field( $_POST['ulgm_user_job_title'] ) );
}
?>"
type="text"/>
</td>
</tr>
<?php
}
// Example of how you might handle the submitted data during registration (requires another hook)
add_action( 'ulgm_user_registration_before_user_creation', 'my_process_custom_registration_fields', 10, 2 );
/**
* Process and save custom registration fields before user creation.
*
* This function is a placeholder to show where you'd typically handle
* saving the data from the custom fields you've added. You would likely
* need to retrieve the data from $_POST and save it as user meta.
*
* @param array $user_data An array of user data being prepared for creation.
* @param array $form_data The full submitted form data.
*
* @since 1.0.0
*/
function my_process_custom_registration_fields( $user_data, $form_data ) {
if ( isset( $form_data['ulgm_user_job_title'] ) && ! empty( $form_data['ulgm_user_job_title'] ) ) {
$job_title = sanitize_text_field( $form_data['ulgm_user_job_title'] );
// You would typically save this to user meta here.
// For demonstration, we'll just log it.
error_log( 'Custom Job Title submitted: ' . $job_title );
// If you were saving it as user meta, it would look something like:
// update_user_meta( $user_id, 'job_title', $job_title );
// Note: $user_id is not directly available here in this hook without further logic.
// You'd often hook into a later stage where the user ID is available.
}
}
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:53
placeholder="<?php esc_html_e( 'Last name', 'uncanny-learndash-groups' ); ?>"
value="<?php if ( ulgm_filter_has_var( 'ulgm_user_last', INPUT_POST ) ) {
echo sanitize_text_field( ulgm_filter_input( 'ulgm_user_last', INPUT_POST ) );
} ?>"
type="text"/></td>
</tr>
<!-- Last name __ END -->
<?php do_action( 'ulgm_groups_registration_form_after_last_name' ); ?>
<?php do_action( 'ulgm_groups_registration_form_before_email' ); ?>
<!-- Email / Username __ START -->
<tr>
<td class="label"><label
for="ulgm_user_email"><?php esc_html_e( 'Email / Username', 'uncanny-learndash-groups' ); ?></label>
</td>
<td class="input">