|
Getting parent post ID sent to user custom field upon Post CRED form submission
Started by: julienL-5
in: Toolset Professional Support
Quick solution available
Problem:
2 CPTs: book, reco-book and book is parent of reco-book
1 CRED form to create a new reco-book positioned on the book post
I am trying to use cred_save_data to record the book parent post id of the reco-book post created through the form into a repeating custom user field named recommended-book-ids.
Solution:
Please use this updated code:
add_action('cred_save_data_160', 'jln_add_book_id',10,2);
function jln_add_book_id($post_id, $form_data)
{
$user_id = get_current_user_id();
$parent_id = get_post_meta($post_id, '_wpcf_belongs_book_id', true);
add_user_meta($user_id, 'wpcf-recommended-book-ids', $parent_id);
}
|
|
2 |
3 |
7 years, 2 months ago
julienL-5
|
|
Displaying CRED error messages near field labels
Started by: michelB
in: Toolset Professional Support
Quick solution available
Problem:
How to display required field error message above taxonomy field in cred form?
Solution:
Please add the following code in your theme’s functions.php file:
add_filter('cred_filter_field_before_add_to_form', 'required_fields_func', 10, 2);
function required_fields_func($field, $computed_values){
$array_of_fields = ('wpcf-myfields', 'taxonomies');
if(in_array($computed_values["name"], $array_of_fields)){
$field['data']['validate']['required'] = array (
'active' => 1,
'value' => 1,
'message' => 'This Field is required!!.'
) ;
}
==> Make sure to replace your field name and taxonomy in this code.
==> You can modify the message text as needed in above code on line #7.
Old ticket with the similar issue and solution summary at top:
https://toolset.com/forums/topic/cred-user-field-not-required/
|
|
3 |
8 |
7 years, 2 months ago
vimalS
|