Kicking things up a notch:
We want to read the fields value (to populate) from a nested user meta (our community meta for each user). This means we need to access the sub-keys.
We also want to write to sub-keys (to maintain a sensical structure for the fields of each team member — relate the fields of a same team member).
And it could even be a little more complex, since we’ll want a sensible structure for the team members as a whole (all team members in an array)
Something like this:
// with 'community' as our user meta key
community = {
eligible: true,
allotment: 3,
activated: true,
team_name: "Griffindor",
team_members: [
{
first_name: "Harry",
last_name: "Potter",
email: "hp@poudlard.edu",
},
{
first_name: "Hermione",
last_name: "Granger",
email: "hermione_granger@poudlard.edu",
},
{
first_name: "Ron",
last_name: "Weazley",
email: "magicweasel@poudlard.edu",
},
]
}
WS Form cannot reach into user meta sub-keys out of the box.
We’ll rely on either PHP functions called from inside the form, or a PHP filter to modify the form content as a whole (likely the latter to read, and the former to write).
(Also, we’re going to make sure we populate the fields server-side, and run our logic there as well, contrary to previous version (whoops.))