Hello,
I previously had help setting up custom post types to generate their own post titles.
I have since modified how forms are filled in and need to have custom post types generate their post titles depending on what is filled out in the form.
I have a form at hidden link
When a new member is filling it out, they choose either Individual or Group.
I need the CPT that is created to use either
Member First Name / Member Last Name
Or
Member Group Name
as the CPT title.
This it the code previously developed with Toolset:
add_filter('cred_save_data','item_title');
function item_title($post_id, $form_data) {
$type = get_post_type($post_id);
if ($type == 'member') {
$c1 = get_post_meta($post_id, 'wpcf-member-first-name', true);
$c2 = get_post_meta($post_id, 'wpcf-member-last-name', true);
$title= $c1. ' ' . $c2;
$slug = sanitize_title($title);
$args = array('ID' => $post_id,
'post_title' => $title,
'post_name' => $slug
);
wp_update_post($args);
}
if ($type == 'donation') {
$c1 = get_post_meta($post_id, 'wpcf-member-first-name', true);
$c2 = get_post_meta($post_id, 'wpcf-member-last-name', true);
$title= $c1. ' ' . $c2;
$slug = sanitize_title($title);
$args = array('ID' => $post_id,
'post_title' => $title,
'post_name' => $slug
);
wp_update_post($args);
}
if ($type == 'material-checkout') {
$parent_id = $_POST["_wpcf_belongs_member_id"];
$title = get_the_title($parent_id);
$slug = sanitize_title($title);
wp_update_post(array('ID' => $post_id, 'post_title' => $title, 'post_status' => 'publish'));
}
if ($type == 'check-in') {
$parent_id = $_POST["_wpcf_belongs_member_id"];
$title = get_the_title($parent_id);
$slug = sanitize_title($title);
wp_update_post(array('ID' => $post_id, 'post_title' => $title, 'post_status' => 'publish'));
}
}
function changenotset($current_options, $title, $type) {
foreach ($current_options as &$option) {
if ($option['#title']=='--- not set ---') {
$option['#title'] = "--- Choose ---";
}
}
return $current_options;
}
add_filter("wpt_field_options", 'changenotset', 10, 3);
Please advise how I might do this.
Thanks.