Home › Forums › Backend Issues (wp-admin) › Dynamically set the value of a field › Reply To: Dynamically set the value of a field
So I’ve changed it to:
/* sets the acf to product type text */
add_filter('acf/load_field/name=product_type', function($field) {
global $post;
$field['value'] = get_product( $post->ID )->get_type();
return $field;
});
… which works, but I get an error (There has been a critical error on this website) when attempting to edit the field group for the acf. What can I do to avoid that (other than temporarily removing the filter above)?
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.