Home Forums Add-ons Flexible Content Field Using acf/update_value in Flexible Content Field Reply To: Using acf/update_value in Flexible Content Field

  • Chasing my tail on this, php-fpm config had a typo in the logging setup, all my debugging was going nowhere… Thanks so much though, I’m very happy to now know how to fetch these values in flex content fields – very helpful!

    So this seems to work very well. For anyone finding this while searching, I use a lazy-loader ( for videos to keep page weight down (and we have some pages with 50+ videos) and for it to look nice and provide flexibility if the user wants to override the default vimeo thumb, I provide a field for the video thumbnail. The user only needs to enter the vimeo video ID.

    If the thumbnail/poster field isleft blank, I want to fetch the URL to the thumbnail from vimeo. This does that.

    	// Fetch vimeo thumbnail on save - takes video ID as input
    	add_filter('acf/update_value/key=field_60412898401c1', 'rf_acf_update_vimeo_thumb_inspo', 20, 4);	
    	function rf_acf_update_vimeo_thumb_inspo( $value, $post_id, $field, $original ) {
    		/* error_log( "in wfh thumb debug, value is $value", 0 );
    		error_log( "in wfh thumb debug, post_id is $post_id", 0 );
    		error_log( "in wfh thumb debug, field is " . print_r($field, true), 0 );
    		error_log( "in wfh thumb debug, original is $original", 0 ); */
    		// only set a new value if the field is empty
    		if ( $value == '') {
    			// get url field's full name (includes flex name, row #, field name concatenated w/"_")
    			$field_name = $field['name'];
    			// strip this field's name from full name
    			$field_name = str_replace('_inspo_thumbnail_url', '', $field_name);
    			// append video ID field to stripped name
    			$field_name .= '_inspo_vimeo_video_id';
    			// use get_post_meta to get the value from the same row (inspo_vimeo_video_id)
      			$vimeo_video_id = get_post_meta($post_id, $field_name, true);
    			// get video here
    			$vimeo_meta = file_get_contents("$vimeo_video_id.json");
    			$vimeo_meta = json_decode($vimeo_meta);
    			$vimeo_thumb = $vimeo_meta[0]->thumbnail_large;
    			// set value
    			$value = $vimeo_thumb;
    			return $value;
    		} else {
    			error_log('$value was not empty',0);
    			return $value;