uo_group_join_form_template
Filters the HTML template used for the group join form, allowing customization before rendering.
add_filter( 'uo_group_join_form_template', $callback, 10, 1 );
Description
Filters the template used for the LearnDash group join form. Developers can modify this hook to customize the HTML structure or content of the group join form displayed to users. This filter fires before the form is rendered.
Usage
add_filter( 'uo_group_join_form_template', 'your_function_name', 10, 1 );
Parameters
-
$form_template(mixed) - This parameter contains the HTML template string for the group join form.
Return Value
The filtered value.
Examples
/**
* Example of modifying the LearnDash group join form template.
* This function will append a custom message before the default form.
*/
add_filter( 'uo_group_join_form_template', function( $form_template ) {
// Check if the provided $form_template is a valid path to a file.
if ( ! file_exists( $form_template ) ) {
// If not, return the original value to avoid errors.
return $form_template;
}
// Get the content of the original form template.
$original_form_content = file_get_contents( $form_template );
// Define our custom message.
$custom_message = '<div class="custom-group-join-message" style="background-color: #e0f7fa; color: #006064; padding: 15px; margin-bottom: 20px; border-left: 5px solid #00acc1;">';
$custom_message .= '<h2>Welcome to our group!</h2>';
$custom_message .= '<p>Please fill out the form below to join this exclusive group and gain access to its resources.</p>';
$custom_message .= '</div>';
// Combine the custom message with the original form content.
$modified_form_content = $custom_message . $original_form_content;
// Save the modified content to a temporary file.
$temp_file_path = tempnam( sys_get_temp_dir(), 'ld_group_form_' ) . '.php';
file_put_contents( $temp_file_path, $modified_form_content );
// Return the path to the temporary file, which will be included by the original function.
// Note: In a real-world scenario, you might want to handle cleanup of temporary files.
return $temp_file_path;
}, 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/classes/learn-dash-group-sign-up.php:1030
public static function check_group_membership() {
$user_id = get_current_user_id();
$group_id = get_the_ID();
$meta = get_user_meta( $user_id, 'learndash_group_users_' . $group_id, true );
if ( ! empty( $meta ) ) {
return;
}
ob_start();
$form_template = self::get_template( 'learndash-group-join-form.php', dirname( dirname( __FILE__ ) ) . '/src' );
$form_template = apply_filters( 'uo_group_join_form_template', $form_template );
include $form_template;
echo ob_get_clean();
}