Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
You can use the Toolset form hook "cred_before_save_data" and assign the value to your desired field.
=> https://toolset.com/documentation/programmer-reference/cred-api/#cred_before_save_data
For example - I've added the following code to "Custom Code" section offered by Toolset with the code snippet namely "toolset-custom-code":
- hidden link
add_action('cred_before_save_data', 'func_save_content_for_generic_field',10,1);
function func_save_content_for_generic_field($form_data) {
// if a specific form
if ($form_data['id']==198) {
if (isset($_POST['post_content_accepted']) and !empty($_POST['post_content_accepted']) ) {
$_POST['post_content'] = $_POST['post_content_accepted'];
}else if(isset($_POST['post_content_rejected']) and !empty($_POST['post_content_rejected']) ) {
$_POST['post_content'] = $_POST['post_content_rejected'];
}
}
}
The above code will assign the selected post content (accepted or rejected) to the default post_content.
Can you please check and let me know if that works now.
No, it isn't.
I don't understand, the code seems correct
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Can you please check now: hidden link
I've adjusted the code added to "Custom Code" section with code snippet "toolset-custom-code" as given under:
=> hidden link
add_action('cred_save_data', 'func_save_content_for_generic_field',10,2);
function func_save_content_for_generic_field($post_id, $form_data) {
// if a specific form
if ($form_data['id']==198) {
if (isset($_POST['post_content_accepted']) and !empty($_POST['post_content_accepted']) ) {
$post_content = $_POST['post_content_accepted'];
}else if(isset($_POST['post_content_rejected']) and !empty($_POST['post_content_rejected']) ) {
$post_content = $_POST['post_content_rejected'];
}
// add it to saved post meta
$my_post = array(
'ID' => $post_id,
'post_content' => $post_content
);
// Update the post into the database
wp_update_post( $my_post );
}
}
Can you please confirm it works as expected now.
Yes, it works.
Now we have just the other issue
2) if I use [wpv-post-link item="@job-candidate.parent"] instead of [wpv-post-title item="@job-candidate.parent"] the the WYSIWYG field has not loaded and it doesn't work
It is strange that it doesn't work but it isn't fundamental
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Can you please check now.
I've adjusted the default value as given under in the form to display the parent post link:
[cred_show_group if="( $(post_title) eq 'accepted' )" mode="fade-slide"]
[cred_generic_field type='wysiwyg' field='post_content_accepted']
{
"default":"Mx. [wpv-post-title] <br /> accepted for \"<a href='[wpv-post-url item="@job-candidate.parent"]'> [wpv-post-title item="@job-candidate.parent"]</a> \" <br /> ciao "
}
[/cred_generic_field]
[/cred_show_group]
[cred_show_group if="( $(post_title) eq 'rejected' )" mode="fade-slide"]
[cred_generic_field type='wysiwyg' field='post_content_rejected']
{
"default":"Mx. [wpv-post-title] <br /> rejectd for \"<a href='[wpv-post-url item="@job-candidate.parent"]'> [wpv-post-title item="@job-candidate.parent"]</a>\" <br /> ciao"
}
[/cred_generic_field]
[/cred_show_group]
Can you please confirm it works as expected now.
I think for the same alternative solution.
thanks, it works
I think for the same alternative solution.
thanks, it works