# Allow Username Edit

**A WordPress plugin that allows administrators to safely edit usernames with an activation checkbox to prevent accidental changes.**

**Author:** Thomas Amundsen
**Contributors:** thaxam
**Author URI:** https://www.thaxam.no/wordpress-plugins/
**Donate link:** https://paypal.me/thaxam
**Requires at least:** 5.8
**Requires PHP:** 7.4
**Tested up to:** 6.8
**License:** GPL-2.0-or-later
**License URI:** https://www.gnu.org/licenses/gpl-2.0.html
**Text Domain:** allow-username-edit

---

## Description

The **Allow Username Edit** plugin provides a secure and user-friendly way for WordPress administrators to edit user usernames. By default, WordPress prevents username changes to maintain data integrity. This plugin overrides that limitation but adds a crucial safety feature: an **activation checkbox**.

The username field is read-only by default, protecting it from accidental edits. To make a change, an administrator must explicitly check the "Activate username editing" box. This two-step process ensures that every username change is intentional.

### Key Features
-   **Safe Username Editing:** Prevents accidental edits by requiring an activation checkbox.
-   **User-Friendly Interface:** Integrates seamlessly into the WordPress user profile screens.
-   **Dynamic Help Text:** The description below the username field updates dynamically to inform the admin whether editing is enabled or protected.
-   **Settings Page:** A dedicated settings page with plugin information, usage instructions, and a link to support future development.
-   **Secure and Compliant:** Follows WordPress best practices, including nonces, permission checks, and a consistent text domain for internationalization.

---

## Installation

1.  Download the latest release from the [WordPress Plugin Repository](https://wordpress.org/plugins/allow-username-edit/) or from this repository.
2.  Upload the `allow-username-edit` folder to the `/wp-content/plugins/` directory on your server.
3.  Activate the plugin through the **Plugins** menu in your WordPress admin area.
4.  (Optional) Visit **Settings > Username Edit** to view plugin information and support options.

---

## Usage

1.  Navigate to **Users > All Users** in your WordPress dashboard.
2.  Click **Edit** on the user whose username you wish to change.
3.  Locate the **Activate username editing** checkbox directly above the **Username** field.
4.  Check the box. The username field will become editable, and the description text will update.
5.  Enter the new username.
6.  Click the **Update User** button at the bottom of the page.
7.  A JavaScript confirmation dialog will appear. Click **OK** to proceed.

---

## Screenshots

For screenshots of the plugin in action, please visit the official plugin page on WordPress.org.

---

## Support the Plugin

If you find this plugin useful, please consider making a donation to support its continued development and maintenance.

<a href="https://paypal.me/thaxam" target="_blank" rel="noopener">
    <img src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" alt="Donate via PayPal" />
</a>

---

## Changelog

### 1.0.6 (2025-09-30)
-   **Security:** Enhanced nonce verification and input sanitization across all user input handling functions.
-   **Fix:** Resolved username saving issue by implementing direct database update with proper validation.
-   **Fix:** Prevented infinite recursion in username update function using static flag.
-   **Tweak:** Corrected plugin asset structure and removed inaccurate screenshot references from readme.txt to adhere to WordPress.org standards.

### 1.0.5 (2025-09-28)
-   **Fix:** Refactored code to remove heredoc syntax, adhering to stricter WordPress coding standards.

### 1.0.4 (2025-09-27)
-   **Fix:** Corrected all internationalization (i18n) function calls to include a consistent text domain (`allow-username-edit`).

### 1.0.3 (2025-09-26)
-   **Fix:** Reworked the checkbox injection logic to use a more reliable `admin_footer` hook.

### 1.0.2 (2025-09-25)
-   **Fix:** Corrected a fatal PHP syntax error.

### 1.0.1 (2025-09-24)
-   **Feature:** Added a checkbox to activate/deactivate username editing.
-   **Feature:** Added a settings page with a PayPal donate link.

### 1.0.0
-   Initial stable version.
