Support Forum
Support › MB Custom Table › Move WordPress User Meta into Custom TableResolved
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?
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
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
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.
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?
Thanks
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?
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
Hi
I have just noticed that whenever a new user or a user updates a profile using metabox forms that the 'first_name' and 'last_name' meta keys are automatically re-added or created under in the database under 'wp_usermeta'. Why is this? is WordPress automatically creating this?