Support

Account

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)?