Skip Navigation

[Resolved] User Fields With CPT custom fields

This support ticket is created 6 years, 9 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by garyF-3 6 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#547426

I am trying to: map user custom field to custom post type field.

I read this https://toolset.com/forums/topic/lack-of-user-integration-will-kill-this-product/

I have a CPT called clients and have a number of custom fields including client_first_name, client_last_name, address, company...

Each client will also be a user of the site, e.g. they need to register their details e.g. first_name, last_name....

The client CPT will need to be linked to other CPT for display of data and queries e.g. child CPT.

I want to pass data from a user custom field to update a custom field. e.g. firstname, lastname, address...

Is this possible using php or some method.

#547714

Dear Gary,

Please describe the question with more details:
I want to pass data from a user custom field to update a custom field. e.g. firstname, lastname, address...

Where and how do you want to pass the data?
If you are using the CRED form for creating/editing post, you can try with CRED action hook cred_save_data to trigger a custom PHP function when user submit the CRED form, in the custom PHP function, update the custom field as what you want, see our document:
cred_save_data
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
This hook allows doing a custom action when post data is saved to database.

You can see PHP code examples by clicking the link "Usage examples" in above document

#547861

Thank you for getting back to me:

So the flow is as follows:

A potential client registers using a form on the website.
The form will have details such as first name, last name, company, website url, address...
(This information needs to be linked to other CPT later)
The person needs initially to be setup as a guest on the site.
If they then purchase a product they will moved to the position of authorised (e.g. post, upload content)
We also have a CPT called clients - we need this populated with the data from the user (client) and do not want them to have to fill this information in again e.g. first name, last name, address, website url.
This client CPT is linked to their Events and enables people to find out more about them and/or search for other clients.

The requirement then is that the user fields be used to update the CPT custom fields.

I hope that makes sense.

Gary

#548166

Thanks for the details, in your case, it needs some custom codes, here is my suggestion:

1) Create a CRED form for creating user, let them fill the custom user fields
https://toolset.com/documentation/user-guides/cred-user-forms/
2) In above CRED form charge payments with CRED Commerce plugin
https://toolset.com/documentation/user-guides/charging-payments-with-cred-to-register-users/
3) After user complete the order, use CRED commerce action hook "cred_commerce_after_order_completed" to trigger a PHP function, in this function do this:
https://toolset.com/documentation/programmer-reference/cred-commerce-api/#cred_commerce_after_order_completed
a) get the custom custom user fields value
https://codex.wordpress.org/Function_Reference/get_user_meta
b) Create a post in "clients" custom post type
https://developer.wordpress.org/reference/functions/wp_insert_post/
c) setup the fields value in above post:
https://developer.wordpress.org/reference/functions/update_post_meta/

#550095

I will have to hire a coder or look into another plugin solution.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.