Home › Forums › General Issues › New ACF type to store multiple fields or arbitrary data › Reply To: New ACF type to store multiple fields or arbitrary data
Hi, I am trying to do something like that as well, here is what i got so far:
lets say you have a custom field with the name “field_1” and one with the name “field_2” and you want the field to return the $value
as an array:
make sure that you custom field html got some input with name="field_1"
and name="field_2"
in the function update_value();
of your custom field put something like:
if( $value ) {
//an array to hold your values
$all_values = array();
$all_values['field_1'] = $value['field_1'];
$all_values['field_2'] = $value['field_2'];
return $all_values;
}
the value of your field is now an array like:
`[“value”]=>
array(2) {
[“field_1”]=>
string(4) “one ”
[“field_2”]=>
string(3) “two”
}
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.