Generate and Log Application Passwords for Specific Users
Last updated 1 month ago
PHP
function generate_app_password_on_login($user_login, $user) {
// Create a new application password for this user
$password = WP_Application_Passwords::create_application_password($user->ID);
// Log the application password creation
$log = fopen(WP_CONTENT_DIR . '/app-password-log.txt', 'a');
fwrite($log, "User {$user->user_login} created an app password: {$password}\n");
fclose($log);
}
add_action('wp_login', 'generate_app_password_on_login', 10, 2);
All code snippets are licensed GPLv2 or later unless otherwise stated.