Hi, I am trying to make the default WYSIWYG post field a required field. I know I could just create a new WYSIWYG field and add this but I have lots and lots of already filled in posts with information in the existing field.
Many thanks in advance.
Hello. Thank you for contacting the Toolset support.
Well - there is no JS solution to make the field required but you can use the Toolset Form's validation hook cred_form_validate to validate your form for the post content field on the server side.
Sure. Can you please share problem URL where you added the form as well as access details.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
Well - I've added the following code to Toolset's Custom Code section "toolset-validate-form ":
=> hidden link
add_filter('cred_form_validate','func_validate_post_content',10,2);
function func_validate_post_content($error_fields, $form_data){
//field data are field values and errors
list($fields,$errors)=$error_fields;
//uncomment this if you want to print the field values
//print_r($fields);
//validate if specific form
if ($form_data['id']==487){
//check my_field value
if ($_POST['post_content']==''){
//set error message for my_field
$errors['post_content']='Empty post conent.';
}
}
//return result
return array($fields,$errors);
}