> For the complete documentation index, see [llms.txt](https://docs.acpt.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.acpt.io/developers/functions/get_acpt_field.md).

# get\_acpt\_field

Fetch a field value

Fetch a field value. Returns the value in its native PHP type.

### Usage

```php
$value = get_acpt_field([
    'post_id'    => 123,
    'box_name'   => 'box',
    'field_name' => 'field',
]);
```

### Parameters

| Parameter              | Type    | Required    | Description                                                                                                                                                                                                                             |
| ---------------------- | ------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `post_id`              | integer | Conditional | The post ID                                                                                                                                                                                                                             |
| `term_id`              | integer | Conditional | The term ID                                                                                                                                                                                                                             |
| `user_id`              | integer | Conditional | The user ID                                                                                                                                                                                                                             |
| `comment_id`           | integer | Conditional | The comment ID                                                                                                                                                                                                                          |
| `wc_product_attribute` | integer | Conditional | The WooCommerce product attribute ID                                                                                                                                                                                                    |
| `option_page`          | string  | Conditional | The option page slug                                                                                                                                                                                                                    |
| `box_name`             | string  | Required    | The meta box name (or a Custom Content Type table name)                                                                                                                                                                                 |
| `field_name`           | string  | Required    | The field name. Use dot notation to reach a nested field, e.g. `repeater_field.child_field` for a Repeater child, or `flexible_field.block_name.field_name` for a field nested inside a Flexible Content block                          |
| `forged_by`            | array   | Optional    | Advanced. Used internally to resolve cloned fields                                                                                                                                                                                      |
| `all_users`            | boolean | Optional    | For a **User** field: return the value regardless of whether the target user still exists                                                                                                                                               |
| `with_context`         | boolean | Optional    | Wrap the returned value(s) in a `{before, value, after}` object using the field's configured before/after text                                                                                                                          |
| `format`               | string  | Optional    | `only_value` (default) returns just the value. `complete` returns the full field object with the value(s) nested inside it                                                                                                              |
| `return`               | string  | Optional    | `object` (default) returns relational fields (Post Object, Term Object, User, etc.) as their native WordPress object (`WP_Post`, `WP_Term`, `WP_User`). `raw` returns the raw stored ID(s) instead. `string` returns a formatted string |

Exactly one of `post_id`, `term_id`, `user_id`, `comment_id`, `option_page`, or `wc_product_attribute` must be provided to identify the location.

### Return

| Type    | Description                                                                                                                                                     |
| ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `mixed` | The field value in its native PHP type (string, integer, array, `WP_Post`, `WP_Term`, `WP_User`, `WPAttachment`, etc. depending on the field type and `return`) |
| `null`  | If the field does not exist or has no saved value                                                                                                               |
