ulgm_groups_registration_form_after_buttons
Fires after the group registration form buttons, allowing for custom content or actions.
add_action( 'ulgm_groups_registration_form_after_buttons', $callback, 10, 1 );
Description
Fires after the registration form's submit and reset buttons are displayed. Developers can use this hook to add custom content or functionality below the core registration buttons, such as additional fields or custom actions, before the form ends.
Usage
add_action( 'ulgm_groups_registration_form_after_buttons', 'your_function_name', 10, 1 );
Examples
<?php
/**
* Example function to add a custom field after the group registration form buttons.
*
* This function demonstrates how to hook into 'ulgm_groups_registration_form_after_buttons'
* to add an additional input field to the group registration form.
*
* @param GroupManagementRegistration $form_instance The instance of the GroupManagementRegistration class.
*/
function my_custom_group_registration_field( $form_instance ) {
// Check if the current user is an administrator or has specific capabilities
// to determine if they should see this custom field.
if ( current_user_can( 'manage_options' ) ) {
?>
<tr>
<th><label for="custom_group_admin_field">Custom Admin Field:</label></th>
<td>
<input type="text" name="custom_group_admin_field" id="custom_group_admin_field" class="regular-text" value="">
<p class="description">This is a custom field only visible to administrators.</p>
</td>
</tr>
<?php
}
}
// Add the custom function to the 'ulgm_groups_registration_form_after_buttons' action hook.
// The '10' is the default priority, and '1' indicates that the callback function
// accepts one argument (the form instance).
add_action( 'ulgm_groups_registration_form_after_buttons', 'my_custom_group_registration_field', 10, 1 );
/**
* Example function to process the custom field data when the form is submitted.
*
* This function demonstrates how to handle the data from the custom field added above
* during the group registration process.
*
* @param int $group_id The ID of the newly created or updated group.
* @param array $form_data An array containing all the submitted form data.
*/
function process_custom_group_registration_field( $group_id, $form_data ) {
// Check if our custom field was submitted and has a value.
if ( isset( $form_data['custom_group_admin_field'] ) && ! empty( $form_data['custom_group_admin_field'] ) ) {
$custom_value = sanitize_text_field( $form_data['custom_group_admin_field'] );
// You would typically save this custom value to the group's metadata.
// Replace 'my_custom_group_meta_key' with your actual meta key.
update_post_meta( $group_id, 'my_custom_group_meta_key', $custom_value );
// You might also want to log this action or send a notification.
error_log( "Custom field 'Custom Admin Field' saved for group ID: " . $group_id . " with value: " . $custom_value );
}
}
// This hook is just an example of where you might process submitted data.
// The actual hook for processing submitted data in Uncanny Groups might be different
// depending on the plugin's structure. For instance, there might be a
// 'ulgm_groups_registration_form_submit_success' or similar.
// This example assumes such a hook exists and passes the group ID and form data.
// You will need to consult the Uncanny Groups documentation for the correct hook.
// For demonstration purposes, let's assume a hypothetical hook:
// add_action( 'ulgm_groups_registration_process_submission', 'process_custom_group_registration_field', 10, 2 );
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:170
value="<?php echo GroupManagementRegistration::$code_registration_atts['code_optional'];
?>"/>
<input type="hidden" name="key"
value="<?php echo crypt( get_the_ID(), 'uncanny-learndash-groups' ); ?>"/>
</td>
</tr>
<!-- Buttons __ END -->
<?php do_action( 'ulgm_groups_registration_form_after_buttons' ); ?>
</table>
<?php do_action( 'ulgm_groups_registration_form_end' ); ?>
</fieldset>
</form>
<script type='text/javascript'>
function check(input) {
if (input.value != document.getElementById('password').value) {