Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('cred_save_data', 'my_save_data_action',10,2);
- function my_save_data_action($post_id, $form_data)
- {
- // Change your Form ID
- if ($form_data['id']==280)
- {
- //Declare the content of your variables
- $custom_title = get_post_meta( $post_id, 'wpcf-firstnamecpt' , true );
- $custom_title.= ' ';
- $custom_title.= get_post_meta($post_id, 'wpcf-last-namecpt', true) ;
- //adding to post_meta because function only appears to take 1 value.
- //collect data and define new title
- $my_post = array(
- 'ID' => $post_id,
- 'post_title' => $custom_title,
- );
- // Update the post into the database
- wp_update_post( $my_post );
- }
- }
- //added cred hook to change post title for cred forms from now on.
- add_action('cred_save_data','combined_title', 10, 2);
- function combined_title($post_id, $form_data) {
- // if a specific form
- if ($form_data['id']==280) {
- $type = get_post_type($post_id, $form_data);
- if ($type == 'staff-member')
- {
- $wpt_intranet_smslug = get_post_meta($post_id, 'wpcf-firstnamecpt', true); //variable declared to hold post ID and fields
- $wpt_intranet_smslug .= get_post_meta($post_id, 'wpcf-last-namecpt', true) ;
- $key = $wpt_intranet_smslug . '-' . $post_id;
- $slug = sanitize_title($key);
- wp_update_post(array('ID' => $post_id, 'post_title' => $key, 'post_name' => $slug));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement