Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Johann Heyne

    (@jonua)

    A tables data is stored in a single custom field as a JSON string in the database like this…
    "{"p":{"o":{"uh":1}},"c":[{"p":""},{"p":""}],"h":[{"c":"Title"},{"c":"Title"}],"b":[[{"c":"Value 1"},{"c":"Value 1"}]]}"

    If you catch the fields value without an ACF function like get_field(), you get this JSON string returned. To get the data as an array, you have to use get_field().

    You could use the following function to decode the JSON string data into the array.

    function acf_table_json_decode( $json ) {
    
    	$a = json_decode( $json, true );
    
    	$return = false;
    
    	// IF BODY DATA
    
    	if ( count( $a['b'] ) > 0 ) {
    
    		// IF HEADER DATA
    
    		if ( $a['p']['o']['uh'] === 1 ) {
    
    			$return['header'] = $a['h'];
    		}
    		else {
    
    			$return['header'] = false;
    		}
    
    		// BODY
    
    		$return['body'] = $a['b'];
    
    		// IF SINGLE EMPTY CELL, THEN DO NOT RETURN TABLE DATA
    
    		if (
    			count( $a['b'] ) === 1
    			AND count( $a['b'][0] ) === 1
    			AND trim( $a['b'][0][0]['c'] ) === ''
    		) {
    
    			$return = false;
    		}
    	}
    
    	return $return;
    }

    To your second request I will reply later.

    Plugin Author Johann Heyne

    (@jonua)

    Version 1.1.8 should enable editing users table data.
    Thanks for reporting that issue!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘The table field does not appear formatted in the front end’ is closed to new replies.