Filter uncanny-toolkit-pro

learndash_reset_link_text

Filters the text displayed for the "reset" link on LearnDash courses and lessons before it is rendered.

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

Description

Filters the text displayed for the "Reset Course Progress" link. Developers can use this hook to dynamically change the link text, perhaps based on user role or course-specific settings. The original text is determined by LearnDash settings, with a fallback if none is found.


Usage

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

Return Value

The filtered value.


Examples

/**
 * Filters the text displayed for the LearnDash course reset button.
 *
 * This example appends a user's name to the reset button text if the user is logged in.
 *
 * @param string $reset_link_text The current text for the reset button.
 * @return string The modified text for the reset button.
 */
add_filter( 'learndash_reset_link_text', function( $reset_link_text ) {
    // Check if the current user is logged in.
    if ( is_user_logged_in() ) {
        $current_user = wp_get_current_user();
        // Append the user's display name to the existing reset button text.
        $reset_link_text .= ' for ' . esc_html( $current_user->display_name );
    }
    return $reset_link_text;
}, 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-reset.php:214

$link_text = self::get_settings_value( 'learn-dash-reset-button-text', __CLASS__ );
				$show_name = self::get_settings_value( 'learn-dash-reset-show-name', __CLASS__ );

				if ( strlen( trim( $link_text ) ) ) {
					$reset_link_text = $link_text;
				}

				$reset_link_text  = apply_filters( 'learndash_reset_link_text', $reset_link_text );
				$referer          = isset( $atts['redirect'] ) && ! empty( $atts['redirect'] ) ? false : true;
				$form_css_classes = apply_filters( 'learndash_reset_form_css_classes', 'learndash-reset-form' );
				$css_classes      = apply_filters( 'learndash_reset_css_classes', 'learndash-reset-button' );
				$nonce_field      = wp_nonce_field( 'learndash_reset_course', 'learndash_reset_course_nonce', $referer, false );

				ob_start();


Scroll to Top