Support

Account

Home Forums Backend Issues (wp-admin) acf/load_field doesn't populate field value for Post Object fields

Unread

acf/load_field doesn't populate field value for Post Object fields

  • – WordPress 5.4.2
    – ACF 5.8.12
    – PHP 7.3.15

    I’m trying to set a default value for a PostObject field. I can set the value just fine, but I can’t detect whether the field is filled out yet, because the acf/load_field hook doesn’t populate $field['value'] on this kind of field.

    
    function themename_default_tracking_campaign($field) {
    	if(empty($field['value'])) { // $field['value'] is always NULL, even if set
    		$field['value'] = ['3956']; // This line always blows away the set value
    	}
    	
    	return $field;
    }
    
    add_filter('acf/load_field/name=pardot_tracking_campaign', 'themename_default_tracking_campaign', 99999999);
    

    I think this is just a plain old bug? In any case, I’d love to know a workaround.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.