I was able to add a ssid with this code below in setup() running on a Photon 2 device os 5.6.0:
#if Wiring_WiFi // check for feature
WiFi.setCredentials("mySSID", "myPassword");
#endif
I try to run the code once then comment it out so it won't run on every startup.
Before I tested this, I came across this thread:
https://community.particle.io/t/keep-permanent-wifi-credentials/65446
I thought this thread might be of interest, too. The P2 is mentioned and a link within about recommended ways to set credentials:
https://community.particle.io/t/argon-wifi-setup-via-normal-serial/64600
Hope this helps.