uo_toolkit_frontend_login_form_data
Filters the data used to display the frontend login form, allowing customization before it's rendered.
add_filter( 'uo_toolkit_frontend_login_form_data', $callback, 10, 1 );
Description
This filter hook allows developers to modify the data passed to the frontend login form. It fires just before the login form's JSON data is generated in the default template. Developers can use this to add or alter form fields, labels, or any other data required for a custom login experience. The hook receives an empty array by default.
Usage
add_filter( 'uo_toolkit_frontend_login_form_data', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
<?php
/**
* Example of how to filter the UO Toolkit frontend login form data.
*
* This example adds a custom error message and a login URL to the data
* that will be available in the frontend JavaScript.
*
* @param array $data The original array of login form data.
* @return array The modified array of login form data.
*/
add_filter( 'uo_toolkit_frontend_login_form_data', function( $data ) {
// Add a custom error message that might be used by the frontend JavaScript.
$data['custom_error_message'] = __( 'Your login attempt failed. Please try again.', 'uncanny-learndash-toolkit' );
// Add a dynamic login URL, perhaps to the default WordPress login page.
$data['login_url'] = wp_login_url();
// Return the modified data array.
return $data;
}, 10, 1 ); // Priority 10, accepts 1 argument.
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/login-page-ui-default.php:8
<?php
namespace uncanny_learndash_toolkit;
?>
<section class="uo_loginForm">
<script>
<?php $json_data = wp_json_encode( apply_filters( 'uo_toolkit_frontend_login_form_data', array() ) ); ?>
let UOToolkitFrontEndLoginFormData = JSON.parse('<?php echo $json_data; ?>');
</script>
<?php
/*
* before_uo_login_ui hook
*
* @arg bool $lost_password