Custom Fields
Re-Envisioned
Support MB REST API Rest API Post to Custom Tables not work

This topic contains 6 replies, has 2 voices, and was last updated by  designerabreu@gmail.com 2 months, 3 weeks ago.

  • Creator
    Topic
  • #14946

    Hello, I have serveral custom post-types with custom fields storing data to custom tables.
    Each custom post-type as is set of fields storing data to custom tables.

    Using rest API to get data by json works fine:

    Example:

    [
      {
        "id": 582,
        "date": "2019-06-12T10:34:17",
        "date_gmt": "2019-06-12T10:34:17",
        "modified": "2019-06-12T12:49:47",
        "modified_gmt": "2019-06-12T12:49:47",
        "slug": "morada-2-4",
        "status": "publish",
        "type": "morada",
        "title": {
          "rendered": "Morada 2"
        },
        "parent": 0,
        "template": "",
        "meta_box": {
          "campo1": "",
          "campo2": ""
        },
    ...

    PROBLEM 1:

    Using POST not working to create or update the meta_box fields:

    {
        "meta_box": {
          "campo1": "some_data1",
          "campo2": "some_data2"
    }

    Wp fields as title ou slug updates is information (stored in wp default database), but the fields “campo1” and “campo2” who stores is data in custom table not update.

    All my sistem is based in custom post-types and custom metabox fields and all post creation ou updates need to be done by json (GET and POST).

    Using custom tables increase organization and loading speed.

    Can you please check? Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Author
    Replies
  • #14956

    Anh Tran
    Keymaster

    Hi, I’ve just tested the plugin and it works fine to me. Here is the video I made for that:

    Update 1: I replied too fast. I didn’t notice you were talking about custom table. Let me check that again.

    Update 2: I’ve just pushed a fix to the plugin here. Can you please try it?

    #14960

    Thank you. I try it and now works fine. Great plugin.

    #14964
    • URGENT IMPORTANT –
      Hello, after applied the fix, posts works fine (GET and POST) but Now custom user fields used in profile are not display in json (even get or to post).

    BEFORE
    “id”: 4,

    “meta_box”: {
    “address”: “Street 123”,
    “postcode”: “4321-123”,
    “region”: “Some”,
    “state”: “Some”,
    “tel”: “121212121”,
    “lat”: “-8.000001”,
    “lon”: “45.000001”,
    “other”: “some info”
    },

    NOW

    “meta_box”: null,
    “_links”: {
    “self”: [

    #15019

    Anh Tran
    Keymaster

    Hi,

    I’ve just tried it with MB User Meta and it works fine. However, I think the fix above doesn’t work well for updating users. I’ll probably need to find a better fix.

    #15046

    Anh Tran
    Keymaster

    After checking the code, I found that the fix actually works. Can you please try again?

    #15136

    Hello, the metabox system is not working in the following situation:

    A data management system based on CUSTOM TABLES was developed for the registration of information, for various reasons, the main one being the organization and speed of data queries.
    The system was created to work with an app, aiming to send and receive data by Rest-API

    At the data level it only uses CUSTOM POST-TYPES, it does not use wordpress post-types.
    Uses CUSTOM TABLES for USER PROFILE data logging of post-types and data logging.

    Problem with user profile data
    It is working correctly via WordPress Back-office. If you create or edit the profile data in Backoffice, you record and change the data added or changed in the table correctly.

    Does not work in the REST API on profile data refresh.
    GET correctly queries data from the defined table (collects data)
    POST does not change the data. When you run a post it does not give an error and displays the data as changed but does not record it in the created table.

    GET Example
    {
    “id”: 4,
    “name”: “Manuel”,
    “url”: “”,
    “description”: “”,
    “link”: “https:\/\/resn.arsites.eu\/arquivo\/author\/agro”,
    “slug”: “agro”,
    “meta”: [],
    “meta_box”: {
    “address”: “Frango assado”,
    “postcode”: “4512-568”,
    “region”: “Nogueiró”,
    “state”: “Braga”,
    “tel”: “253123456”,
    “lat”: “-8.56885555”,
    “lon”: “45.5898989”,
    “other”: “Nada a informar”
    },
    “_links”: {
    “self”: [
    {
    “href”: “https:\/\/resn.arsites.eu\/wp-json\/wp\/v2\/users\/4”
    }
    ],
    “collection”: [
    {
    “href”: “https:\/\/resn.arsites.eu\/wp-json\/wp\/v2\/users”
    }
    ]
    }
    }

    POST Example

    “meta_box”: {
    “address”: “Rua das Casas 12666”,
    “postcode”: “4512-568”,
    “region”: “Nogueiró”,
    “state”: “Braga”,
    “tel”: “253123456”,
    “lat”: “-8.56885555”,
    “lon”: “45.5898989”,
    “other”: “Nada a informar agora”
    },

    Example GET after POST (nothing change)

    “meta_box”: {
    “address”: “Frango assado”,
    “postcode”: “4512-568”,
    “region”: “Nogueiró”,
    “state”: “Braga”,
    “tel”: “253123456”,
    “lat”: “-8.56885555”,
    “lon”: “45.5898989”,
    “other”: “Nada a informar”
    },

    The example user’s address is https://resn.arsites.eu/wp-json/wp/v2/users/4
    If you wish I can indicate an access to the system

Viewing 6 replies - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.