Updating Custom WordPress User Meta Field via REST API

I hope to help you put in the right direction. Be welcome to the community and don’t forget to update your question with the code that you tried in order to give more examples to the community.

Let’s get to the issue.

First, you have added the user data in the meta table, through the add_user_meta function. That’s right to save the data, but add_user_meta does not exposes the field itself in the REST API. You need to register first that field into the API, for the users type:

add_action('rest_api_init', function() {
    register_rest_field( 'user', 'phone_number', [
        'get_callback'    => 'get_user_phone_number',
        'update_callback' => 'update_user_phone_number',
        'schema'          => [
                                'type'        => 'string',
                                'description' => 'The phone number ...',
                                'context'     => [ 'view', 'edit' ],
                             ],
    ]);
});

function get_user_phone_number( $user, $field_name, $request ) { 
    return get_user_meta( $user[ 'id' ], $field_name, true );
}

function update_user_phone_number( $user, $meta_value ) { 
    update_user_meta( $user[ 'id' ], 'phone_number', $meta_value );
}

While the schema argument is frequently neglected, it offers you a lot in terms of validation for basic types of fields, you could even make your own validation function in order to avoid invalid information, but for a lot of things, just using the right type of field in the schema will help you a lot.