Hi @thnpanagiotidis
Unfortunately, this requires customization on your end. You can try the following code snippets to enable the username in the Profile Form:
add_filter("um_user_profile_restricted_edit_fields","um_111921_allow_username_edit");
function um_111921_allow_username_edit( $restricted_fields ){
unset( $restricted_fields[2] );
return $restricted_fields;
}
add_action("um_submit_form_profile","um_111921_username_validation", 1 );
function um_111921_username_validation( $post_form ){
if( isset( $post_form['user_login'] ) && ! empty( $post_form['user_login'] ) ){
$user = wp_get_current_user();
if( username_exists( $post_form['user_login'] ) && $post_form['user_login'] !== $user->user_login ){
UM()->form()->add_error( 'user_login', __( 'Your username is already taken', 'ultimate-member' ) );
}
}
}
add_action("um_user_after_updating_profile","um_111921_update_username", 9999999, 3 );
function um_111921_update_username( $to_update, $user_id, $args ){
global $wpdb;
$user = wp_get_current_user();
$sql = $wpdb->prepare("UPDATE {$wpdb->users} SET user_login = %s WHERE ID = %d", $to_update['user_login'], $user_id );
$wpdb->query($sql);
// Log-in again.
wp_set_auth_cookie($user->ID);
wp_set_current_user($user->ID);
do_action('wp_login', $user->user_login, $user);
}
When you update the username, the account will be logged-out as per WP core design. You can add the code to your theme/child-theme’s functions.php file or use the Code Snippet plugin to run the code.
Regards,