Filter uncanny-learndash-toolkit

wp_2fa_login_button_text

Filters the text displayed on the 2FA login button, allowing customization of the login button label.

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

Description

This filter allows developers to customize the text displayed on the login button for Two-Factor Authentication. It modifies the default "Log In" text, offering flexibility in how login actions are presented to users.


Usage

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

Return Value

The filtered value.


Examples

<?php
/**
 * Example of how to filter the text displayed on the WP 2FA login button.
 *
 * This callback function modifies the default 'Log In' text to 'Sign In'
 * for a more personalized user experience, assuming a specific scenario
 * where 'Sign In' is preferred.
 *
 * @param string $button_text The original text of the login button.
 * @return string The modified text for the login button.
 */
add_filter( 'wp_2fa_login_button_text', 'my_custom_wp_2fa_login_button_text', 10, 1 );

function my_custom_wp_2fa_login_button_text( $button_text ) {
	// Replace the default 'Log In' text with 'Sign In'
	// This is a simple example, in a real-world scenario, you might check
	// for specific user roles or other conditions before changing the text.
	if ( $button_text === esc_html__( 'Log In', 'wp-2fa' ) ) {
		return esc_html__( 'Sign In', 'wp-2fa' );
	}

	return $button_text; // Always return the value to prevent breaking the filter.
}
?>

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/two-factor/providers/wp-2fa/legacy/class-frontend-login-plus-2fa-2.6.php:705
src/includes/two-factor/providers/wp-2fa/legacy/class-frontend-login-plus-2fa-2-4.php:644
src/includes/two-factor/providers/wp-2fa/legacy/class-frontend-login-plus-2fa-2-3.php:613
src/includes/two-factor/providers/wp-2fa/legacy/class-frontend-login-plus-2fa-2-5.php:643

<?php $submit_button_disabled = apply_filters( 'wp_2fa_login_disable_submit_button', false, $user, $provider ); ?>

			<?php if ( ! $submit_button_disabled ) : ?>
				<?php do_action( 'wp_2fa_login_before_submit_button', $user, $provider ); ?>
				<p>
					<?php
					if ( function_exists( 'submit_button' ) ) {
						$button_text = apply_filters( 'wp_2fa_login_button_text', esc_html__( 'Log In', 'wp-2fa' ) );
						submit_button( $button_text );
						?>
						<script type="text/javascript">
							setTimeout(function () {
								var d
								try {
									d = document.getElementById('authcode')


Scroll to Top