Skip Navigation

[Resolved] Cred form – Parse user CF value to CF in post form

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.

This topic contains 1 reply, has 1 voice.

Last updated by TomW5440 1 year, 8 months ago.

Author
Posts
#2429427
tools.png

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/

#2429443

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.

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