Change WiFi password by access point (Arduino IOT cloud project)

I must admit I don't fully understand wifimanager myself and find the examples very confusing...
The best I have managed to figure out and the simplest way to use it I implement in the below sketch.
BTW - If anyone has suggestions how I can do it better it would be gratefully received