Skip Navigation

[Resolved] populating custom post fields with custom user fields (both managed by types)

This support ticket is created 5 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 5 replies, has 3 voices.

Last updated by davelow 5 years, 7 months ago.

Assisted by: Christian Cox.

Author
Posts
#1250269

Tell us what you are trying to do?
making post fields = user fields. Is there a way to dynamically copy user fields to post fields?
Is there any documentation that you are following?
cannot find any. would be great if there is a reference
Is there a similar example that we can see?

What is the link to your site?

#1250291

There's nothing that will automatically do this for you. You have a few options I can think of:
1. Create custom code that automates this using WordPress APIs and Toolset APIs. We offer several APIs and documentation for retrieving information from user and post fields. You would need a general understanding of PHP and WordPress concepts to make this work. If that's not something you're familiar with, you can get professional assistance at either of these contractor portals: https://toolset.com/contractors or hidden link
2. Export the User field data and re-import it as post field data associated with all posts. This approach is really only practical if the field copy process is a one-time thing (i.e. post fields do not reflect ongoing changes in User fields).
3. If you just want to display User field information in a post, then it might not be necessary to copy the fields over. You just need to store a reference to the User in a post field. For example, you could store a User ID in a post field, then use that User ID to access the User field from inside the post. This approach has a limitation in that you cannot filter or search a View of posts using those User fields.

Let me know if you need more information about any of these options.

#1250743

Thanks Christian,

Looks like its option (1). Please provide the references for me. I'll have a go at it before approaching the professionals.

Thanks again.

#1251363

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi dave,

Christian is currently off on holidays today but will be back tomorrow to continue with you on this.

Thanks for the patience.

#1252129

Here are some WordPress event hooks you might find useful:
https://codex.wordpress.org/Plugin_API/Action_Reference/save_post
https://codex.wordpress.org/Action_Reference/profile_update

Some WordPress APIs you may use:
https://developer.wordpress.org/reference/functions/get_post_meta/
https://developer.wordpress.org/reference/functions/update_post_meta/
https://codex.wordpress.org/Function_Reference/get_user_meta/
https://codex.wordpress.org/Function_Reference/update_user_meta/

The APIs for displaying Types field information are documented here:
https://toolset.com/documentation/customizing-sites-using-php/functions/
Click +More beneath any field type to see examples of post fields and user fields.

Note that custom fields created by Types use the 'wpcf-' prefix in the database. So if your custom field slug in wp-admin is 'schedule' then the database slug is 'wpcf-schedule'.

#1263679

My issue is resolved now. Thank you!