settings(); $settings->add_tab( 'users', __( 'Users', 'all-in-one-utilities' ), __( 'Settings that affect how user accounts are managed.', 'all-in-one-utilities' ), 20 ); $settings->add_section( 'users', 'username_updater', __( 'Username Updater', 'all-in-one-utilities' ), __( 'Let administrators change a user\'s username directly from the Users screen.', 'all-in-one-utilities' ), 10 ); $settings->add_field( 'users', 'username_updater', new Field( id: 'enabled', label: __( 'Enable Username Updater', 'all-in-one-utilities' ), type: 'checkbox', default: 0, args: array( 'toggle_label' => __( 'Allow administrators to update usernames', 'all-in-one-utilities' ) ), doc: new Doc( title: __( 'Username Updater', 'all-in-one-utilities' ), short: __( 'Adds an "Update username" action to every user in the Users list.', 'all-in-one-utilities' ), detailed: __( 'WordPress does not normally allow changing a username after account creation. This updates it directly and safely, and can notify the user by email.', 'all-in-one-utilities' ), warnings: array( __( 'Changing a username does not change the user\'s login email or password.', 'all-in-one-utilities' ) ) ), priority: 10 ) ); $settings->add_field( 'users', 'username_updater', new Field( id: 'notify_by_default', label: __( 'Notify user by email', 'all-in-one-utilities' ), type: 'checkbox', default: 0, args: array( 'toggle_label' => __( 'Check the email notification box by default', 'all-in-one-utilities' ), 'depends_on' => 'enabled', ), doc: new Doc( title: __( 'Email notification default', 'all-in-one-utilities' ), short: __( 'Controls the default state of the "notify user" checkbox on the update form.', 'all-in-one-utilities' ), detailed: __( 'The administrator can still override this on a per-update basis before submitting the form.', 'all-in-one-utilities' ) ), priority: 20 ) ); // The "Username Updated" email lives on the Emails tab; show it here // too, so everything about this feature is configurable in one place. $settings->add_mirror( 'users', 'username_updater', 'emails', 'user_emails', 'username_updated', 10 ); if ( $settings->get_value( 'users', 'username_updater', 'enabled', 0 ) ) { ( new Feature() )->register(); } } }