Having an admin account, I can change everything except the username (which happens to be the login name). I am therefore wondering how to change the username using the functions file.
Running the below as a SQL query works fine, but how do I "convert" it into a function?
add_action('init','username_query');
function username_query() {
global $wpdb;
$result = (UPDATE `wp_users` SET `user_login`= 'new-admin-name-here' WHERE `user_login`='old-admin-name-here');
}
Any help is appreciated and yes; I know that the user will be logged out and asked to login again.