Filter uncanny-learndash-toolkit

uo_frontend_login_modal_page_lockout_detection

Filters whether to display the lockout message after a login attempt when the modal is shown.

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

Description

This filter hook allows developers to control the lockout detection logic for the frontend login modal page. By default, it enables detection. Developers can return `false` to disable it or modify the lockout behavior. This hook fires during the rendering process of the login page.


Usage

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

Parameters

$post (mixed)
This parameter likely indicates whether lockout detection is enabled or not, based on the context of the `uo_frontend_login_modal_page_lockout_detection` filter.

Return Value

The filtered value.


Examples

/**
 * Example filter to disable lockout detection on the login page under specific conditions.
 *
 * This function checks if the current post is the designated login page and,
 * if a specific user role (e.g., 'administrator') is logged in, it returns false
 * to disable the lockout detection for that scenario.
 *
 * @param bool $should_validate The current value of lockout detection (default is true).
 * @param WP_Post $post The current post object.
 * @return bool Returns false if the current user is an administrator and the post is the login page, otherwise returns the original $should_validate.
 */
add_filter( 'uo_frontend_login_modal_page_lockout_detection', function( $should_validate, $post ) {
	// Check if the user is logged in and has the administrator role.
	if ( is_user_logged_in() && current_user_can( 'manage_options' ) ) {
		// Optionally, you could also check if the $post is the designated login page,
		// though the source context already handles this check before applying the filter.
		// For this example, we'll assume this filter is only applied when $post is relevant.

		// Disable lockout detection for administrators on the login page.
		return false;
	}

	// Otherwise, maintain the default lockout detection behavior.
	return $should_validate;
}, 10, 2 ); // Priority 10, accepts 2 arguments.

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/frontend-login-plus.php:2806

public static function maybe_add_ui_shortcode() {

		global $post;

		$settings = get_option( 'FrontendLoginPlus', array() );

		foreach ( $settings as $setting ) {
			if ( 'login_page' === $setting['name'] && '0' !== $setting['value'] ) {
				$login_page_id = $setting['value'];
				if ( $post instanceof WP_Post && $post->ID === (int) $login_page_id ) {
					$should_validate = apply_filters( 'uo_frontend_login_modal_page_lockout_detection', true, $post );
					$should_validate = filter_var( strtolower( $should_validate ), FILTER_VALIDATE_BOOLEAN );
					if ( $should_validate && ! has_shortcode( $post->post_content, 'uo_login_ui' ) && ! has_block( 'uncanny-toolkit/frontend-login', $post->post_content ) ) {
						echo '<div id="ult-login-no-setup-notice"><strong>';
						_e( 'Note: This page has been set as the login page for this site. The form below has been added for your convenience. To hide this message, add the shortcode [uo_login_ui] or the Front End Login Gutenberg block to this page.', 'uncanny-learndash-toolkit' );
						echo '</strong></div>';
						echo do_shortcode( '[uo_login_ui]' );
					}
				}
			}
		}
	}

Scroll to Top