I have a Post Edit form and it has one form field which collects user data for a custom field. Now in the frontend, the form field displays the custom field value in it. I don't want to show it. How can I remove it?
Hello. Thank you for contacting the Toolset support.
Do you mean that you want to show the field on edit form with blank/empty value and allow users to add another value or what if you remove the field directly from the form it user intervention is not required?
add_filter('cred_filter_field_before_add_to_form', 'func_adjust_conflict_conditions', 10, 1);
function func_adjust_conflict_conditions($field){
$form_id = 0;
$form_html_id = $field['form_html_id'];
if ( isset($form_html_id) ) {
$parts = explode( '_', $form_html_id);
$form_id = (int) $parts[2];
}
$field_slugs = array('book');
if($form_id==99999 and in_array($field['id'],$field_slugs)){
// in some cases $fields['data'] is an empty string, so you'll need to first set it's expected format for PHP 7.1 compatibility
if (!is_array($field['data'])) {
$field['data'] = array();
}
$field['field_value'] = '';
}
return $field;
}
Where:
- Replace $field_slugs with your original field slug.
- Replace 99999 with your original form ID.
Can you please share problem URL where you added your form as well as admin 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.