Hello,
I have been a lot with Toolset over the last few months to create a fairly unique system for a creative reuse space.
I have two custom codes that have been made by the Toolset support team and they have worked great up until now.
I have one custom code that saves custom fields as the CPT title.
https://toolset.com/forums/topic/custom-post-types-generate-their-own-post-titles-from-1-or-2-custom-fields/
//Save Member name as post title.
add_action('cred_save_data','func_custom_post_title', 10, 2);
function func_custom_post_title($post_id,$form_data) {
$arr = array(12, 13); // here you can add more CRED form IDs
if (in_array($form_data['id'], $arr)) {
$type = get_post_meta($post_id, 'wpcf-member-type', true);
$title = '';
if ($type == 'individual') {
$firstname = get_post_meta($post_id, 'wpcf-member-first-name', true);
$lastname = get_post_meta($post_id, 'wpcf-member-last-name', true);
$title = $firstname. ' ' . $lastname;
}
if ($type == 'group') {
$groupname = get_post_meta($post_id, 'wpcf-member-group-name', true);
$title = $groupname;
}
if($title){
$slug = sanitize_title($title);
$args = array(
'ID' => $post_id,
'post_title' => $title,
'post_name' => $slug
);
wp_update_post($args);
}
}
}
I have another custom code that calculates the sum of custom fields
https://toolset.com/forums/topic/number-fields-sum-for-specific-post-types-and-fields/
//Calculate membership fields
add_action("wpt_field_options", 'changenotset', 10, 3);
function count_numeric_custom_field_func( $atts ) {
global $wpdb;
extract( shortcode_atts( array(
'field' => '',
'cpt' => '',
'decimals' => 2,
'format_decimals' => 2,
), $atts ) );
$count = $wpdb->get_var( $wpdb->prepare(
"
SELECT SUM(CAST(meta_value AS DECIMAL (15,{$decimals}))) as count
FROM $wpdb->posts p
INNER JOIN $wpdb->postmeta pm
ON p.id = pm.post_id
WHERE p.post_type = %s
AND p.post_status = 'publish'
AND meta_key = %s
",
$cpt,
$field
) );
if (empty($count)){
$count = 0;
}
return number_format($count, $format_decimals);
}
add_shortcode( 'count_numeric_custom_field', 'count_numeric_custom_field_func' );
I have setup the two codes as separate plugins. However, when I activate the second, "calculate the sum of custom fields", form fields on the front end of the site disappear. I have attached screenshots.
I just did another test and it is when only the second code is activated that the front end form fields disappear. Is it maybe interfering with form functionality?
Please advise.