Fill MB CF group in user profile with n8n via API, fields remain empty

Support MB User Profile Fill MB CF group in user profile with n8n via API, fields remain empty

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #48379
    Matthias BerndtMatthias Berndt
    Participant

    I created the following group as custom fields in the user profiles and defined them as cloneable.

    <?php
    $groups = rwmb_meta( 'mb_user_agb_akzeptiert', [ 'object_type' => 'user' ], get_current_user_id() );
    foreach ( $groups as $group ) {
    	
    	// Field agb_akzeptiert_datum:
    	echo $group[ 'agb_akzeptiert_datum' ] ?? '';
    	
    	// Field agb_akzeptiert_ja:
    	$checkbox = $group[ 'agb_akzeptiert_ja' ] ?? 0;
    	if ( $checkbox ) {
    		echo 'Checked';
    	} else {
    		echo 'Unchecked';
    	}
    	
    	// Field agb_akzeptiert_bemerkung:
    	echo $group[ 'agb_akzeptiert_bemerkung' ] ?? '';
    
    }
    ?>

    If I then send the following JSON data with n8n, it is received, but I can also retrieve it again with n8n and display it in the frontend using the first code.

    What doesn't work, however, is that this data doesn't appear in the user's form fields.

    The date field remains empty, the checkbox remains unchecked, and the text

    {
      "meta_box": {
        "mb_user_agb_akzeptiert": [{
          "agb_akzeptiert_datum": "2025-06-05",
          "agb_akzeptiert_ja": true,
          "agb_akzeptiert_bemerkung": "AGB Akzeptiert"
        }]
      }
    }
    #48383
    PeterPeter
    Moderator

    Hello Matthias,

    Can you please provide more information about the issue?

    - What is the REST API URL you use to send and get the field value?
    - Can you check the user meta key and value in the table wp_usermeta and confirm that the updated value is stored in the database?
    - Please export the field group and share it with me. I will import it to my demo site and investigate the issue.
    - Also share the form shortcode that you are using.

    Thank you.

    #48403
    Matthias BerndtMatthias Berndt
    Participant

    Hello Peter,

    Sorry I couldn't reply sooner because I had to resolve another issue in the meantime, but unfortunately I haven't been able to restore the data entry (which I obviously corrupted during testing).

    Currently, no data is being saved that I send from n8n to the WordPress site for the fields.

    - REST-API-URL: https://domain.tld/wp-json/wp/v2/users/15/
    - I didn't find the entry in the wp_usermeta, but in the wp_postmeta.
    - https://pastebin.com/Y9GgQqDA (Here is the custom fields code.)
    - https://pastebin.com/7DLw36Lg (The registration form is implemented with Bricksforge Pro Forms and the data to be entered is sent to n8n via webhook, as I have not yet found a way to save this data directly from a registration form in the user profile.)

    My goal is to ask the user, if any of the texts change later, to confirm these texts again and not to overwrite these confirmations, but to add to them, so that later on it is still possible to see which of the changes the user has accepted.

    Thank you, Kind regards
    Matthias

    #48414
    PeterPeter
    Moderator

    Hello,

    I import the field group "Rechtliche Zustimmungen" to my demo site and see that:
    - the field group location is set to Post instead of User
    - the option "Save field value" of the group field is not enabled to save data and display data.
    see these screenshots

    https://ibb.co/JwJwpdQJ
    https://ibb.co/nsdTCJh6

    Please correct them, then follow the documentation and test to push some demo data to your site without using Bricks form and third-party n8n API to see if it works.
    https://docs.metabox.io/extensions/mb-rest-api/

    Let me know how it goes.

    #48417
    Matthias BerndtMatthias Berndt
    Participant

    The first problem was the forgotten prefix for the field IDs within the group, which is why the data wasn't being output. Saving the groups wasn't configured, but saving the group elements was already configured, and the group was already set to User.

    Now these entries are being accepted by the API and output in the profile.

    The next problem I'm having is that further entries aren't being accepted via the API, or they're just overwriting the first ones instead of adding to them.

    User-Custom-Fields:
    https://pastebin.com/b3reqg4A

    n8n JSON for HTTP-Request
    https://pastebin.com/BqiEDmZR

    Database-Data:
    https://pastebin.com/SrX0pPNh

    The entries from the form contain the following data at the end of the first entry, which is no longer included in subsequent entries.

    ;s:6:"_state";s:8:"expanded";

    These aren't included in the API entries. Could this be the cause, or what am I doing wrong?

    #48425
    PeterPeter
    Moderator

    Hello,

    Thanks for the details. I'm discussing the issue with the development team and I will get back to you soon.

    #48427
    Matthias BerndtMatthias Berndt
    Participant

    Hello Peter,

    Thanks, but do you perhaps have any idea what the following data is supposed to do and why it only appears in the first entry of a data record entered via a user form and not via the API?

    ;s:6:"_state";s:8:"expanded";

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.