I have a Cred form used to create a 'practitioner' (a custom post type), including several custom fields and custom taxonomies. I am using the post title in place of a dedicated custom field for the practitioner's name for simplicity's sake. What I would like is to automatically create a custom tag using the post title when the cred form is saved. My custom taxonomy slug is 'person'.
I have seen other similar topics on the forum (http://wp-types.com/forums/topic/cred-saving-user-submitted-custom-field-as-post-title/), but I have not been able to get that solution to work. Perhaps it is because a taxonomy requires different treatment?
I have created a functions.php in my child theme and I have added the following code, with no luck so far:
add_action('cred_save_data_[513]','practitioner_title_tag'); function practitioner_title_tag($post_id) { $type = get_post_type($post_id); if ($type == 'practitioner') { $title_tag = get_post_meta($post_id, 'post_title', true); $slug = sanitize_title($title_tag); wp_update_post(array('ID' => $post_id, 'person' => $title_tag, 'post_name' => $slug)); } }
Any help you can provide would be appreciated!