Filter uncanny-toolkit-pro

uo_group_login_form_template

Filters the HTML template used for the group login form, allowing customization before it is displayed.

add_filter( 'uo_group_login_form_template', $callback, 10, 1 );

Description

Filters the HTML template used for the group login form. Developers can modify or completely replace the form's structure and content by returning their custom HTML. This hook fires before the form is displayed and is intended for advanced customization of the group login experience.


Usage

add_filter( 'uo_group_login_form_template', 'your_function_name', 10, 1 );

Parameters

$form_template (mixed)
This parameter contains the HTML template for the group login form.

Return Value

The filtered value.


Examples

// Example of using the 'uo_group_login_form_template' filter to modify the login form's HTML structure.
// This example adds a custom heading above the default login form.
add_filter( 'uo_group_login_form_template', 'my_custom_group_login_form_template', 10, 1 );

/**
 * Modifies the group login form template by adding a custom heading.
 *
 * @param string $form_template The path to the default login form template.
 * @return string The modified path to the login form template or a custom HTML string.
 */
function my_custom_group_login_form_template( $form_template ) {
    // In a real scenario, you might want to check if the user is already logged in
    // or if there are specific conditions under which you want to apply this customization.
    // For demonstration, we'll assume we always want to add this heading.

    // Check if the provided template is a file path.
    if ( is_string( $form_template ) && file_exists( $form_template ) ) {
        // Read the content of the default template.
        $template_content = file_get_contents( $form_template );

        // Prepend our custom HTML to the existing template content.
        $custom_html = '<h2>Welcome to Our Groups! Please Log In</h2>';
        $modified_content = $custom_html . $template_content;

        // Return the modified HTML content directly, bypassing the original file inclusion.
        // This is a more direct way to inject custom content.
        // Alternatively, you could create a new template file with your modifications.
        return $modified_content;
    }

    // If the $form_template is not a valid file path or is already a string of HTML,
    // you might want to handle it differently. Here, we'll just return it as is,
    // or you could prepend your custom HTML if it's already a string.
    // For simplicity, this example assumes the filter is applied before the file is included.
    // If the hook is intended to modify the *path* to a template file, the logic would be different.
    // Based on the source context, it seems to be used to modify the content *after* the template is retrieved.

    // If $form_template is already HTML content, you can prepend to it.
    if ( is_string( $form_template ) ) {
        $custom_html = '<h2>Welcome to Our Groups! Please Log In</h2>';
        return $custom_html . $form_template;
    }

    // Fallback: If we can't modify, return the original value.
    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:750

public static function groups_login_form( $context = '' ) {
		if( true !== apply_filters( 'uo_show_groups_login_form', true, $context ) ) {
			return;
		}

		if ( is_user_logged_in() ) {
			ob_start();
			esc_html_e( 'You're already signed in! We hope you're enjoying our courses.', 'uncanny-pro-toolkit' );
			$page_link = self::get_page_link_settings( 'uo_groups_page_link' );
			$page_text = self::get_page_link_settings( 'uo_groups_page_link_text' );
			if ( self::is_url( $page_link ) ) {
				printf( '<br /><a href="%s">%s</a>', esc_url( $page_link ), esc_html( $page_text ) );
			}

			return ob_get_clean();
		} else {
			ob_start();
			$form_template = self::get_template( 'groups-login-form.php', dirname( dirname( __FILE__ ) ) . '/src' );
			$form_template = apply_filters( 'uo_group_login_form_template', $form_template );
			include $form_template;

			return ob_get_clean();
		}
	}


Scroll to Top