Support Forum » User Profile

Forum Replies Created

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • in reply to: Rest API Post to Custom Tables not work #15136
    designerabreu@gmail.com[email protected]
    Participant

    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

    in reply to: Rest API Post to Custom Tables not work #14964
    designerabreu@gmail.com[email protected]
    Participant
    • 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": [
    ...

    in reply to: Rest API Post to Custom Tables not work #14960
    designerabreu@gmail.com[email protected]
    Participant

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

    in reply to: Custom Taxonomy and Advanced Taxonomy #14403
    designerabreu@gmail.com[email protected]
    Participant

    Thanks a lot. solved

    in reply to: Use MB User Meta data in meta box #14402
    designerabreu@gmail.com[email protected]
    Participant

    Works fine, thanks to show the way. Best regards

    in reply to: Meta box fields as stock info? #14349
    designerabreu@gmail.com[email protected]
    Participant

    Works fine. Thanks a lot

    in reply to: Use MB User Meta data in meta box #14171
    designerabreu@gmail.com[email protected]
    Participant

    Hello, thanks to help get it works. The concept is reverse. Post get some data from user profile. Changed code to this:

    add_action( 'rest_api_init', function () {
        register_rest_field( 'post', 'ag_name', array(
            'get_callback' => function( $user ) {
                $product = get_post_meta( $user['id'], 'the_user', true );
                return get_user_meta( $product, 'ag_name', true );
            },
        ) );
        register_rest_field( 'post', 'ag_address', array(
            'get_callback' => function( $user ) {
                $product = get_post_meta( $user['id'], 'the_user', true );
                return get_user_meta( $product, 'ag_address', true );
            },
        ) );
        register_rest_field( 'post', 'ag_post_code', array(
            'get_callback' => function( $user ) {
                $product = get_post_meta( $user['id'], 'the_user', true );
                return get_user_meta( $product, 'ag_post_code', true );
            },
        ) );
    } );

    In the metabox field set of the article, I added a filed "the_user" with the author (user field), to identify the user fields, according to the example you have indicated. When the user is indicated, it works correctly, associating the information registered in the profile of the user with the article.

    Any possibility of this field or the identification code be automatic? The user field gives not only the user but the list of all users. In json output there is already the variable "author": 123 so instead of manually set the user, I could use this.

    But I do not know how to use it here:
    $ product = get_post_meta ($ user ['id'], 'the_user', true);

    Instead of "the_user" use the "author". The author as the id of user to get the user fields info.

    Thanks a lot

    in reply to: Use MB User Meta data in meta box #14145
    designerabreu@gmail.com[email protected]
    Participant

    Hello, tanks but i am lost.
    I am not a programmer so some easy easy things are not so easy to me
    Where I put the code?

    The pratical case:
    1. I use a set of metaboxes to fill user information (adress, telephone, city, custom email, latitude and longitude).
    Json request give metabox to /wp-json/wp/v2/users/id
    "meta_box": {
    "ag_name": "User1",
    "ag_adress": "Custom adress",
    "ag_post_code": "1234-987",
    "ag_region": "Local",
    "ag_state": "City",
    "ag_phone": "123456789",

    1. The post has another set of metaboxes with extra info about product.
      Once exists multiples authors, I need add to some fields the data already filled on user profile on the user metabox setup above:

    Example post output needed:

    "meta_box": {
    //set of fields auto filled with user profile - get data from user metaboxes//

    "ag_name": "User1",
    "ag_adress": "Custom adress",
    "ag_post_code": "1234-987",
    "ag_region": "Local",
    "ag_state": "City",
    "ag_phone": "123456789",
    

    //set of fields filled in the post//

    "to_quantity": "100",
    "to_description": "Custom description",
    "to_advantages": "Custom text",
    

    ...

    So json output combine the information of post with information i want show about the author.
    Each post get is author extend author information.

    Thanks for your patience

Viewing 8 posts - 1 through 8 (of 8 total)