showing results for - "getting data from json e2 80 93 acf plugin"
Lea
26 May 2016
1function acf_json_ipm($json_acf_url_field, $acf_radio_field) {
2        
3        //Check if data field is set to Manual
4        if (get_field($json_acf_url_field) == 'manual') {
5            // Stop importing from JSON
6            return;
7        }
8        
9            //Make a request
10            $json_request = wp_remote_get( $json_acf_url_field );
11            if( is_wp_error( $json_request ) ) {
12                return false; // Bail early
13            }
14            
15            // Get JSON and Decode
16            $json_body = wp_remote_retrieve_body( $json_request );
17            $json_data = json_decode( $json_body );
18           
19            // Import values from JSON
20            $values = array (
21                
22                'field_1234' => $json_data->value1, 
23                'field_5678' => array (
24                    'field_8901' => $json_data->value2, 
25                    'field_2345' => $json_data->value3, 
26                    'field_6789' => $json_data->value4 
27                ),
28                'field_0123' => $json_data->value5, 
29            );
30
31            //Update Group field and save1
32            update_field('acf_group_field_key', $values);
33            
34            //Put the checkbox to manual
35            update_field($acf_radio_field, 'manual');
36       }
similar questions
queries leading to this page
getting data from json e2 80 93 acf plugin