uo_group_registration_form_template
Filters the template used to display the group registration form, allowing modification of its HTML structure.
add_filter( 'uo_group_registration_form_template', $callback, 10, 1 );
Description
Filters the HTML template used for the Uncanny Groups registration form. Developers can modify this to customize the form's appearance or structure, or even replace it entirely with their own custom HTML. This hook fires before the form is rendered on the page.
Usage
add_filter( 'uo_group_registration_form_template', 'your_function_name', 10, 1 );
Parameters
-
$form_template(mixed) - This parameter holds the HTML template for the group registration form, allowing for its modification.
Return Value
The filtered value.
Examples
/**
* Modifies the group registration form template.
*
* This filter allows developers to change the default template file used for the
* group registration form. For instance, one might want to use a custom template
* with additional fields or styling.
*
* @param string $form_template The default path to the group registration form template.
* @return string The modified path to the group registration form template.
*/
add_filter( 'uo_group_registration_form_template', 'my_custom_group_registration_form_template', 10, 1 );
function my_custom_group_registration_form_template( $form_template ) {
// Get the current user's ID.
$current_user_id = get_current_user_id();
// Example: Only apply the custom template if the current user is an administrator.
if ( current_user_can( 'manage_options' ) ) {
// Define the path to your custom template.
// Replace 'path/to/your/custom-group-registration-form.php' with the actual path.
$custom_template_path = plugin_dir_path( __FILE__ ) . 'custom-templates/admin-group-registration-form.php';
// Check if the custom template file exists before returning it.
if ( file_exists( $custom_template_path ) ) {
$form_template = $custom_template_path;
}
}
// Return the potentially modified form template path.
return $form_template;
}
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/classes/learn-dash-group-sign-up.php:590
public static function groups_register_form() {
// check to make sure user registration is enabled
//$registration_enabled = get_option( 'users_can_register' );
//@version 3.3 Ticket#9851
$registration_enabled = true;
?>
<div class="uncanny_group_signup_form-container">
<?php
// only show the registration form if allowed
if ( $registration_enabled ) {
// show any error messages after form submission
self::uncanny_group_signup_show_error_messages();
$form_template = self::get_template( 'group-registration-form.php', dirname( dirname( __FILE__ ) ) . '/src' );
$form_template = apply_filters( 'uo_group_registration_form_template', $form_template );
include $form_template;
} else {
?>
<div class="uncanny_group_signup_form-container__error">
<?php
echo esc_attr__( 'User registration is not enabled. Contact Site Administrator.', 'uncanny-pro-toolkit' );
?>
</div>
<?php
}
?>
</div>
<?php
}