Home › Forums › General Issues › Unable to write multiple values ACF user field back to DB › Reply To: Unable to write multiple values ACF user field back to DB
Update:
I was able to write the string: ‘a:1:{i:0;s:2:”57″;}’ back to the database.
And then tried: ‘a:2:{i:0;s:2:”55″;i:1;s:2:”57″;}’ and also ‘a:3:{i:0;s:2:”55″;i:1;s:2:”57″;i:2;s:2:”60″;}’, they worked too.
so maybe that is the way I need to fix this.
Any suggestions for the most efficient way to code this?
To recap:
I pull the string from the database, may be 0 characters, on up… in that string array.
I’ll need to add a new one to the end that and then put it back into the database.
So:
$old_current_mentees = ‘a:1:{i:0;s:2:”55″;}’ or ‘a:2:{i:0;s:2:”55″;i:1;s:2:”57″;}’ or ‘a:3:{i:0;s:2:”55″;i:1;s:2:”57″;i:2;s:2:”62″;}’; etc
add new_mentee = a:2:{i:0;s:2:”55″;i:1;s:2:”68″; to the string array
make sure it has the proper wrappers
$new_current_mentees = $old_current_mentees + new_mentee
write it to a variable to upload back into the DB.
Any suggestions for the most efficient way to code this? Functions to use? Sample code?
Thanks!
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.