retrieve the custom fields values of a certain post
343870
function mf_get_post_values( $post_id ) {
    global $wpdb;

    $raw = $wpdb->get_results(
      "SELECT
        mfpm.meta_id,
        mfpm.field_name,
        mfpm.field_count,
        mfpm.group_count,
        pm.meta_value
      FROM
        ".MF_TABLE_POST_META." as mfpm
      LEFT JOIN
       ".$wpdb->postmeta." as pm
      ON
        ( mfpm.meta_id = pm.meta_id )
      WHERE
        mfpm.post_id = ".$post_id
    );

    $data = array();

    foreach( $raw as $key => $field ){
      $data[$field->field_name][$field->group_count][$field->field_count] = $field->meta_value;
    }

    return $data;
  }
847657
def valuefrompostdata(self, postdata):
        """"""
        if self.id in postdata and postdata[self.id] != '':
            return int(postdata[self.id])
        else:
            return None
111152
public function customFieldsToArray()
    {
        $result = [];
        foreach ($this->getCustomFields() as $field) {
            $result[$field->getInternalFieldName()] = $field->getValue();
        }

        return $result;
    }
912951
def get_current_fields(self):
        """"""
        if hasattr(self, 'current_fields') and self.current_fields:
            return self.current_fields

        field_attribute = 'list_{}_{}_fields'.format(self.kwargs.get('app'), self.kwargs.get('model'))
        current_fields = self.request.user.attributes.get_attribute(field_attribute, [])
        request_fields = self.request.POST.get('selected_fields', None)

        if request_fields and ','.join(current_fields) != request_fields:
            # TODO validate fields
            current_fields = request_fields.split(',')
            self.request.user.attributes.set_attribute(field_attribute, current_fields)
        elif request_fields:
            current_fields = request_fields.split(',')

        if not current_fields:
            config = self.get_model_config()
            current_fields = config.list_default_fields if config.list_default_fields else ['created_at', 'id']

        self.current_fields = current_fields
        return current_fields
1230989
public function loadPOST()
    {
        $post = $_POST;

        $this->hook('loadPOST', [&$post]);
        $errors = [];

        foreach ($this->fields as $key => $field) {
            try {
                $value = isset($post[$key]) ? $post[$key] : null;

                // save field value only if field was editable in form at all
                if (!$field->readonly && !$field->disabled) {
                    $this->model[$key] = $this->app->ui_persistence->typecastLoadField($field->field, $value);
                }
            } catch (\atk4\core\Exception $e) {
                $errors[$key] = $e->getMessage();
            }
        }

        if ($errors) {
            throw new \atk4\data\ValidationException($errors);
        }
    }
1145153
function attachment_fields_to_edit( $form_fields, $post ) 
	{
		// vars
		$screen = get_current_screen();
		$post_id = $post->ID;
		

		if( $screen && $screen->base == 'post' ) {
			
			return $form_fields;
			
		}
		
		
		// get field groups
		$filter = array( 'post_type' => 'attachment' );
		$metabox_ids = array();
		$metabox_ids = apply_filters( 'acf/location/match_field_groups', $metabox_ids, $filter );
		
		
		// validate
		if( empty($metabox_ids) )
		{
			return $form_fields;	
		}
		
		
		$acfs = apply_filters('acf/get_field_groups', array());
	
	
		if( is_array($acfs) ){ foreach( $acfs as $acf ){
			
			// only add the chosen field groups
			if( !in_array( $acf['id'], $metabox_ids ) )
			{
				continue;
			}
			
			
			// load fields
			$fields = apply_filters('acf/field_group/get_fields', array(), $acf['id']);
			
			
			if( is_array($fields) ){ foreach( $fields as $i => $field ){
				
				// if they didn't select a type, skip this field
				if( !$field || !$field['type'] || $field['type'] == 'null' )
				{
					continue;
				}
					
			
				// set value
				if( !isset($field['value']) )
				{
					$field['value'] = apply_filters('acf/load_value', false, $post_id, $field);
					$field['value'] = apply_filters('acf/format_value', $field['value'], $post_id, $field);
				}
				
				
				// create field
				$field['name'] = 'fields[' . $field['key'] . ']';
				
				ob_start();
					
					do_action('acf/create_field', $field);
					
					$html = ob_get_contents();
				
				ob_end_clean();
 
				
				$form_fields[ $field['name'] ] = array(
		       		'label' => $field['label'],
		   			'input' => 'html',
		   			'html' => $html
				);
				
			}};
 
			
		}}
		
		
		// return
		return $form_fields;
	}
1209557
public function getSparseAndFieldSetsExample(): string
    {
        $author   = Author::instance('123', 'John', 'Dow');
        $comments = [
            Comment::instance('456', 'Included objects work as easy as basic ones', $author),
            Comment::instance('789', 'Let\'s try!', $author),
        ];
        $post = Post::instance('321', 'Included objects', 'Yes, it is supported', $author, $comments);
        $site = Site::instance('1', 'JSON API Samples', [$post]);

        SiteSchema::$isShowCustomLinks = false;
        $encoder                       = Encoder::instance([
            Author::class  => AuthorSchema::class,
            Comment::class => CommentSchema::class,
            Post::class    => PostSchema::class,
            Site::class    => SiteSchema::class
        ])->withEncodeOptions(JSON_PRETTY_PRINT);

        $result = $encoder
            ->withIncludedPaths([
                // Paths to be included. Note 'posts.comments' will not be shown.
                'posts',
                'posts.author',
            ])
            ->withFieldSets([
                // Attributes and relationships that should be shown
                'sites'  => ['name', 'posts'],
                'posts'  => ['author'],
                'people' => ['first_name'],
            ])
            ->encodeData($site);

        return $result;
    }
205000
def __get_value(self, field_name):
        
        value = request.values.get(field_name)
        if value is None:
            if self.json_form_data is None:
                value = None
            elif field_name in self.json_form_data:
                value = self.json_form_data[field_name]
        return value
835812
public function get_update_data_params(
		/** @noinspection PhpUnusedParameterInspection */
		$post, $update
	) {
		$params = [];
		foreach ( $this->get_data_field_settings() as $k => $v ) {
			$params[ $k ] = $this->get_post_field( $k, $update || ! $v['required'] ? null : $v['default'], null, $v );
			$params[ $k ] = $this->sanitize_input( $params[ $k ], $v['type'] );
			if ( ! isset( $params[ $k ] ) && ! $update && $v['unset_if_null'] ) {
				unset( $params[ $k ] );
				continue;
			}
		}

		return $params;
	}
1176537
private function FetchFields($res)
    {
        if (!$this->debug_on) {
            return ;
        }
        $i=0;
        $this->col_info = array();
        while ($i < @pg_num_fields($res)) {
            $this->col_info[$i]->name = @pg_field_name($res, $i);
            $this->col_info[$i]->size = @pg_field_size($res, $i);
            $this->col_info[$i]->type = @pg_field_type($res, $i);
            $i++;
        }
    }
1081037
def get_model_custom_fields(self):
        
        return CustomField.objects.filter(
            content_type=ContentType.objects.get_for_model(self))
353688
def format_custom_fields(list_of_custom_fields):
        '''
            
        '''
        output_payload = {}
        if list_of_custom_fields:
            # custom_field: {"name": value}
            for custom_field in list_of_custom_fields:
                for key, value in custom_field.items():
                    output_payload["custom_fields[" + key + "]"] = value
        return output_payload
481707
def get_custom_fields(self, search=None, start=1, limit=50):
        
        url = 'rest/api/2/customFields'
        params = {}
        if search:
            params['search'] = search
        if start:
            params['startAt'] = start
        if limit:
            params['maxResults'] = limit
        return self.get(url, params=params)
1118245
private function getAllSetData()
    {
        $data = [];
        foreach ($this->customFields as $customField) {
            $data[$customField->getName()] = $customField->getValue();
        }

        return $data;
    }
932166
def parse_form(self, req, name, field):
        """"""
        return get_value(req.body_arguments, name, field)
355546
def get_post_data(self):
        '''
        
        '''
        post_data = {}
        for key in self.request.arguments:
            post_data[key] = self.get_arguments(key)[0]
        return post_data
1209514
def parse_form(self, req, name, field):
        """"""
        return core.get_value(req.POST, name, field)