Custom Fields
Re-Envisioned
Support MB Custom Table Move WordPress User Meta into Custom Table

  • Creator
    Topic
  • #28910
    Resolved Nicholas Cox
    Participant

    Hi

    I am about to create a custom table to store user meta. But I noticed the users 'first_name' and 'last name' exists within the _usermeta database table. Is it possible to alter the way WordPress store this and move it from here into my custom table? or would I just have to ignore this and leave them blank/empty and then add in a first and last name column into my custom table?

    Cd2fnV.md.jpg

    I was thinking about when I come to make front end calls to grab the users custom meta, from my custom table, that the only 2 fields I would be missing are the first and last names. Would I have to query the first and last name separately? as I ideally wanted to achieve calling all the users meta in one for loop within my template.

    Thanks, hope I'm making sense. Maybe I'm just overthinking the above query.

    Nick

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #28931
    Long Nguyen
    Moderator

    Hi Nicholas,

    When editing or creating a user from the frontend, you can follow this documentation to replace the default user first name and last name fields and save data to the custom table https://docs.metabox.io/extensions/mb-user-profile/#edit-default-fields

    #29011
    Nicholas Cox
    Participant

    Hi, ok thanks for this, I have created my fields and custom table and used the same ID's e.g. first_name etc and it does store the fields into my custom table correctly.

    custom table

    But I also noticed that it also stores the value into the 'wp_usermeta' table too. Is this correct? Is it supposed to behave like this?

    user_meta table

    Thanks

    #29016
    Long Nguyen
    Moderator

    Hi,

    If you register the user with the custom fields first_name, last_name on the frontend, the field value only saved in the custom table. But if you update the user info in the backend Admin dashboard > Users > Profile, the field value will be saved in both the custom table and the default table wp_usermeta because first_name, last_name are two default custom fields of WordPress. Can you please register a new user and re-check it?

    #29037
    Nicholas Cox
    Participant

    Hi

    Ah I was updating those fields in the backend, I have tested this in the front end form now and I can confirm it does not save it to the wp_usermeta table.

    Thanks

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