Tell us what you are trying to do?
I'm trying to parse CF value from user to a CF in the Cred form of a post and based on this value then insert another value into a CF.
Here's the workflow -
A user registers for an account and pays before user account is created. The CF in the user table is a radio 'account type' which relates to product variations . The values are:
402790
402791
402792
402793
From here they can login and add a CP 'Agent'.
The Agent CPT includes CF's 'Agent Account Type' and 'Property Count'.
So I want the Agent Account Type CF value to be inserted from the User CF Account Type value.
And then depending on the CF value a different value be inserted into the Property Count CF.
Something a bit like -
add_action( 'cred_save_data', 'my_save_data_action', 10, 2 );
function my_save_data_action($post_id, $form_data) {
// if a specific form
if ( $form_data[ 'id' ] == 402396 ) { //Make sure you set the correct ID of your for
$product_count = get_post_field ('post_account_type',$_POST['agent-account-type']);
$my_post = array(
'ID' => $post_id,
'post_account' => $product_count
);
if ($product_count == 402790) {
$product_count = 1;
}
else if ($product_count == 402791) {
$product_count = 100;
}
else if ($product_count == 402792) {
$product_count= 500;
}
else if ($product_count == 402793) {
$product_count = 1000;
}
// Update the post author ID into the database
wp_update_post( $my_post );
}
}
Is there any documentation that you are following?
https://toolset.com/forums/topic/passing-custom-field-values-into-another-custom-field-via-cred/
My issue is resolved now. Thank you!
This was surprisingly easy. I added the value to the field in the post form without the need of a special function.