ACPT v2
  • General
    • Minimum requirements
    • Download the plugin
    • Install ACPT
    • Install ACPT with Composer
    • Managing your license
    • Migrating from v1
      • Fix data loss after migration from V1
    • Settings
    • Translations
    • How to open a ticket
  • Basics
    • Custom post types
    • Taxonomies
    • Post type-Taxonomy association
    • Option pages
  • Meta fields
    • Field groups
    • The meta fields manager
      • Group settings
      • Basics
      • Advanced options
      • Conditional rendering
      • Validation rules
    • Field types
      • Address field
      • Audio field
      • Audio multiple field
      • Color field
      • Country field
      • Currency field
      • Date field
      • Datetime field
      • Date range field
      • Editor field
      • Email field
      • Embed field
      • File field
      • Gallery field
      • HTML field
      • Icon field
      • Image field
      • Length field
      • List field
      • Number field
      • Password field
      • Phone field
      • QR Code field
      • Select, checkbox, and radio
      • Rating field
      • Repeater field
      • Relational field
      • Range field
      • Table field
      • Textarea field
      • Text field
      • Time field
      • Toggle field
      • URL field
      • Video field
      • Weight field
  • Permissions manager
    • Custom post types permissions
    • Taxonomies permissions
    • Option pages permissions
    • Meta fields permissions
  • Tools
    • Custom APIs
    • Health check
    • Datasets
    • Export data
    • Import data
  • Forms
    • Manage forms
    • The form builder
    • Examples of form usage
      • Create a new post type
      • Modify an existing post type
      • Create a new term
      • Modify an existing term
      • Create a new user
      • Modify an existing user
    • Form submissions log
  • Dynamic blocks
    • Create your first block
  • Developers
    • Functions
      • register_acpt_post_type
      • delete_acpt_post_type
      • register_acpt_taxonomy
      • delete_acpt_taxonomy
      • assoc_acpt_taxonomy_to_acpt_post
      • remove_assoc_acpt_taxonomy_from_acpt_post
      • register_acpt_option_page
      • delete_acpt_option_page
      • save_acpt_form
      • delete_acpt_form
      • save_acpt_form_field
      • delete_acpt_form_field
      • get_acpt_form_object
      • get_acpt_form_field_object
      • save_acpt_meta_group
      • delete_acpt_meta_group
      • get_acpt_meta_group_objects
      • get_acpt_meta_group_object
      • save_acpt_meta_box
      • delete_acpt_meta_box
      • get_acpt_box_object
      • save_acpt_meta_field
      • delete_acpt_meta_field
      • get_acpt_meta_field_objects
      • get_acpt_meta_field_object
      • save_acpt_meta_field_value
      • delete_acpt_meta_field_value
      • get_acpt_fields
      • acpt_field_has_rows
      • acpt_field_has_blocks
      • get_acpt_field
      • get_acpt_child_field
      • get_acpt_block
      • get_acpt_block_child_field
      • acpt_field
      • is_acpt_field_visible
    • Shortcodes
  • Integrations
    • API Rest field integration
    • Breakdance
      • Build a real estate website
      • Working with nestable fields
    • Bricks builder
      • Build a real estate website
      • Working with nestable fields
      • Working with Slider (Nestable) and Gallery field
      • Working with relational fields inside query loops
      • Additional options
      • Working with text links
    • Divi
    • Elementor
      • Basic field blocks
      • Nestable field blocks
      • Dynamic tags
    • Gutenberg
      • Basic fields block
      • Relational fields block
      • Repeater fields block
      • Working with FSE
    • Oxygen builder
    • Rank Math
    • SEOPress
    • Slim SEO
    • WooCommerce
    • WP All Import/Export
    • WP Grid Builder
    • WPGraphQL
    • WPML
    • Yoast
    • Zion builder
Powered by GitBook
On this page
  • Read operations
  • Write operations
  1. Integrations

API Rest field integration

API Rest field integration

PreviousShortcodesNextBreakdance

Last updated 1 year ago

ACPT comes with custom integration with the standard .

Read operations

Suppose you have registered a custom meta field called text for native posts.

Call a GET request to the endpoint:

/wp-json/wp/v2/posts

Inside the post objects, you'll find the node called acpt:

{
   "id":2274,
   "date":"2022-02-22T12:46:10",
   "date_gmt":"2022-02-22T12:46:10",
   "guid":{
      "rendered":"http://localhost:83/?p=2274"
   },
   "modified":"2022-02-22T13:00:09",
   "modified_gmt":"2022-02-22T13:00:09",
   "slug":"ciao",
   "status":"publish",
   "type":"post",
   "link":"http://localhost:83/ciao/",
   "title":{
      "rendered":"Ciao"
   },
   "content":{
      "rendered":"\n<p>lorem ispum</p>\n",
      "protected":false
   },
   "excerpt":{
      "rendered":"<p>lorem ispum</p>\n",
      "protected":false
   },
   "author":1,
   "featured_media":0,
   "comment_status":"open",
   "ping_status":"open",
   "sticky":false,
   "template":"",
   "format":"standard",
   "meta":[

   ],
   "category":[
      47
   ],
   "post_tag":[

   ],
   "other":[

   ],
   "acpt":{
      "meta":[
         {
            "meta_box":"info",
            "meta_fields":[
               {
                  "name":"text",
                  "type":"Text",
                  "options":[

                  ],
                  "value":"",
                  "default":"",
                  "required":false,
                  "showInAdmin":false
               }
            ]
         }
      ]
   },
   "_links":{}
}
/wp-json/wp/v2/product

in this case the acpt object contains also a key called wc_product_data, an array of field objects:

[
    {
        "id": 2003,
        "date": "2022-01-21T14:50:29",
        "date_gmt": "2022-01-21T14:50:29",
        "guid": {
            "rendered": "http://localhost:83/?post_type=product&#038;p=2003"
        },
        "modified": "2022-02-23T11:28:30",
        "modified_gmt": "2022-02-23T11:28:30",
        "slug": "nuovo-prodotto",
        "status": "publish",
        "type": "product",
        "link": "http://localhost:83/product/nuovo-prodotto/",
        "title": {
            "rendered": "Nuovo prodotto"
        },
        "content": {
            "rendered": "<p>um has been the industry&#8217;s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.um has been the industry&#8217;s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.um has been the industry&#8217;s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>\n",
            "protected": false
        },
        "excerpt": {
            "rendered": "<p>um has been the industry&#8217;s standard dummy text ever since the 1500s, when an unknown printer took a galley of [&hellip;]</p>\n",
            "protected": false
        },
        "featured_media": 1142,
        "comment_status": "open",
        "ping_status": "closed",
        "template": "",
        "meta": [],
        "product_cat": [
            16
        ],
        "product_tag": [],
        "acpt": {
            "meta": [],
            "wc_product_data": [
                {
                    "name": "Product data",
                    "icon": {
                        "icon": "storefront",
                        "value": "\\e900"
                    },
                    "visibility": [
                        "show_if_simple",
                        "show_if_variable",
                        "show_if_grouped",
                        "show_if_external"
                    ],
                    "fields": [
                        {
                            "name": "field",
                            "type": "Text",
                            "options": [],
                            "value": "",
                            "default": "",
                            "required": false
                        }
                    ]
                }
            ]
        },
        "_links": {
            "self": [
                {
                    "href": "http://localhost:83/wp-json/wp/v2/product/2003"
                }
            ],
            "collection": [
                {
                    "href": "http://localhost:83/wp-json/wp/v2/product"
                }
            ],
            "about": [
                {
                    "href": "http://localhost:83/wp-json/wp/v2/types/product"
                }
            ],
            "replies": [
                {
                    "embeddable": true,
                    "href": "http://localhost:83/wp-json/wp/v2/comments?post=2003"
                }
            ],
            "wp:featuredmedia": [
                {
                    "embeddable": true,
                    "href": "http://localhost:83/wp-json/wp/v2/media/1142"
                }
            ],
            "wp:attachment": [
                {
                    "href": "http://localhost:83/wp-json/wp/v2/media?parent=2003"
                }
            ],
            "wp:term": [
                {
                    "taxonomy": "product_cat",
                    "embeddable": true,
                    "href": "http://localhost:83/wp-json/wp/v2/product_cat?post=2003"
                },
                {
                    "taxonomy": "product_tag",
                    "embeddable": true,
                    "href": "http://localhost:83/wp-json/wp/v2/product_tag?post=2003"
                }
            ],
            "curies": [
                {
                    "name": "wp",
                    "href": "https://api.w.org/{rel}",
                    "templated": true
                }
            ]
        }
    },
    {
        "id": 35,
        "date": "2020-06-03T16:42:23",
        "date_gmt": "2020-06-03T16:42:23",
        "guid": {
            "rendered": "http://localhost:83/?post_type=product&#038;p=35"
        },
        "modified": "2022-01-21T14:56:08",
        "modified_gmt": "2022-01-21T14:56:08",
        "slug": "prodotto-bello",
        "status": "publish",
        "type": "product",
        "link": "http://localhost:83/product/prodotto-bello/",
        "title": {
            "rendered": "Prodotto bello"
        },
        "content": {
            "rendered": "<p>Lorem ipsum</p>\n",
            "protected": false
        },
        "excerpt": {
            "rendered": "<p>Lorem ipsum</p>\n",
            "protected": false
        },
        "featured_media": 0,
        "comment_status": "open",
        "ping_status": "closed",
        "template": "",
        "meta": [],
        "product_cat": [
            16
        ],
        "product_tag": [],
        "acpt": {
            "meta": [],
            "wc_product_data": [
                {
                    "name": "Product data",
                    "icon": {
                        "icon": "storefront",
                        "value": "\\e900"
                    },
                    "visibility": [
                        "show_if_simple",
                        "show_if_variable",
                        "show_if_grouped",
                        "show_if_external"
                    ],
                    "fields": [
                        {
                            "name": "field",
                            "type": "Text",
                            "options": [],
                            "value": "",
                            "default": "",
                            "required": false
                        }
                    ]
                }
            ]
        },
        "_links": {
            "self": [
                {
                    "href": "http://localhost:83/wp-json/wp/v2/product/35"
                }
            ],
            "collection": [
                {
                    "href": "http://localhost:83/wp-json/wp/v2/product"
                }
            ],
            "about": [
                {
                    "href": "http://localhost:83/wp-json/wp/v2/types/product"
                }
            ],
            "replies": [
                {
                    "embeddable": true,
                    "href": "http://localhost:83/wp-json/wp/v2/comments?post=35"
                }
            ],
            "wp:attachment": [
                {
                    "href": "http://localhost:83/wp-json/wp/v2/media?parent=35"
                }
            ],
            "wp:term": [
                {
                    "taxonomy": "product_cat",
                    "embeddable": true,
                    "href": "http://localhost:83/wp-json/wp/v2/product_cat?post=35"
                },
                {
                    "taxonomy": "product_tag",
                    "embeddable": true,
                    "href": "http://localhost:83/wp-json/wp/v2/product_tag?post=35"
                }
            ],
            "curies": [
                {
                    "name": "wp",
                    "href": "https://api.w.org/{rel}",
                    "templated": true
                }
            ]
        }
    }
]

Write operations

To write field data via API, make a POST request to the same endpoint:

/wp-json/wp/v2/posts

You have to add acpt node to the usual JSON payload.

Suppose you want to create a new post with the title "Lorem ipsum":

{
   "title": "Lorem ipsum",
   "acpt": {
      "meta": [
         {
            "box": "info",
            "field": "text",
            "value": "This is the value"
         }
      ]
   }
}

Please note that some fields require the value to be an array.

For example, suppose you have a select multiple field called select within a meta box called info:

{
   "title": "Lorem ipsum",
   "acpt": {
      "meta": [
         {
            "box": "info",
            "field": "select",
            "value": [
               "This is the value",
               "This is another value",
               "This is the third value",
            ]
         }
      ]
   }
}

If you have installed try to call:

WordPress API Rest
WooCommerce