Support

Account

Home Forums ACF PRO update_field returning large int instead of bool Reply To: update_field returning large int instead of bool

  • @hube2 That’s good to know. I actually ended up arriving at that solution a while ago, so I am using field keys, but the issue keeps happening.

    I don’t think I can edit my original post anymore, but the ACF_Module class has those field keys stored as parameters (so I don’t have to keep changing it everywhere). So near the end of my PHP code, $module->documents_field is the same as field_6255b86755ad6.

    Here is an example set of data for $documents_field:

    
    $documents_field = [
        [ 'document_id' => 2241, 'module_id' => 201, 'order' => 1.0 ],
        [ 'document_id' => 2242, 'module_id' => 201, 'order' => 2.0 ],
        [ 'document_id' => 2243, 'module_id' => 201, 'order' => 3.0 ],
    ];
    
    $documents_field_deleted = delete_field('field_6255b86755ad6', 201);
    
    $documents_field_updated = update_field('field_6255b86755ad6', $documents_field, 201);
    

    I’m even making sure that each int is an int or float by using the intval() and floatval() functions. But for some reason, this isn’t working.

    Not sure if this helps, but here’s the declaration and constructor for my ACF_Module class:

    
    // ACF_Post is another custom class that just contains the same parameters as the WP_Post object, which isn't extendable
    class ACF_Module extends ACF_Post
    {
        public $documents = [];
        public $post_type = 'acf_module';
    
        public $documents_field = 'field_6255b86755ad6';
    
        public function __construct($post_id, $attr = [], $module_id = -1)
        {
            $post_id = intval($post_id);
    
            parent::__construct($post_id, $attr);        
            $this->documents   = !empty(get_field($this->documents_field, $post_id))   ? get_field($this->documents_field, $post_id) : false;
        }
    // [...]
    }