Filter uncanny-learndash-toolkit

uo_frontend_login_args

Modify default arguments of the WP Login form Missing elements are defined in the fetch_login_from_args method of the FrontendLoginPlus class: src/classes/frontend-login-plus.php Filters the default arguments used for the frontend login form, allowing customization of form element IDs.

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

Description

Filter the arguments used to generate frontend WordPress login forms. This hook allows developers to customize form IDs, labels, and other attributes, providing granular control over the login experience. It fires before the login form is rendered, enabling dynamic adjustments based on specific needs or themes.


Usage

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

Return Value

The filtered value.


Examples

/**
 * Example of modifying the uo_frontend_login_args filter.
 * This function will append a custom class to the login form and change
 * the ID of the submit button.
 *
 * @param array $login_args The array of arguments for the frontend login form.
 * @return array The modified array of arguments.
 */
add_filter( 'uo_frontend_login_args', function( $login_args ) {
    // Add a custom class to the form for additional styling via CSS.
    if ( ! isset( $login_args['form_attributes'] ) ) {
        $login_args['form_attributes'] = [];
    }
    $login_args['form_attributes']['class'] = isset( $login_args['form_attributes']['class'] ) ? $login_args['form_attributes']['class'] . ' custom-frontend-login' : 'custom-frontend-login';

    // Change the ID of the submit button for easier targeting with JavaScript.
    $login_args['id_submit'] = 'my-custom-login-submit-button';

    // You could also modify other elements, for example, adding a custom message before the form:
    // $login_args['before_form'] = '<p>Welcome back! Please log in to continue.</p>';

    return $login_args;
}, 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/templates/frontend-login/default-login.php:27
src/templates/frontend-login/layout_1-login.php:75
src/templates/frontend-login/modern_ui-login.php:75
src/classes/frontend-login-plus.php:1816

/**
 * Modify default arguments of the WP Login form
 * Missing elements are defined in the fetch_login_from_args method of
 * the FrontendLoginPlus class: src/classes/frontend-login-plus.php
 */

$login_form_args = apply_filters( 'uo_frontend_login_args', array_merge( FrontendLoginPlus::fetch_login_form_args(), [
	'form_id'     => 'ult-login-form',
	'id_username' => 'ult-login-email',
	'id_password' => 'ult-login-password',
	'id_remember' => 'ult-login-remember',
	'id_submit'   => 'ult-login-submit',
]));


Scroll to Top