Home › Forums › Feature Requests › Dynamically Set ACF Field Default Value › Reply To: Dynamically Set ACF Field Default Value
@commandz – Any chance you’re still checking this? (Or anyone else who understands it?) I am trying to do this very thing, but I need to populate the default value with the value of another ACF field from a specific page.
Here’s how I tried to implement it in functions.php, but it’s not working:
$address = get_field('center_address', 342);
add_filter('acf/load_field/name=contact_info',
function($field) use ($address) {
$field['default_value'] = $address;
return $field;
}
);
I’m trying to populate the value of field “contact_info” with the value from “center_address”, from post 342. I’m trying to do this on a backend form on the post editing screen, not a frontend form.
I’m using ACF Pro. The center_address and contact_person field are text fields.
THANK YOU!
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!
🎉ACF has made it into the latest round of the @TheTorqueMag Plugin Madness!
— Advanced Custom Fields (@wp_acf) March 22, 2023
🙏 Please swing by and vote for ACF in the latest matchup.
🙌 Each round lasts one week, but you can vote twice each week. Make sure to get both your votes in!https://t.co/iTpRE82O1k
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.