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.
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
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
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/
I will have to hire a coder or look into another plugin solution.