Advertisement
Guest User

Untitled

a guest
Oct 24th, 2018
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1. function cred_nice_log_item_titles($post_id, $form_data) {      
  2.     // Log Item Form
  3.     if ( $form_data["id"]==302 ) {
  4.         $date_format = get_option('date_format');
  5.         $date = get_post_meta($post_id, 'wpcf-date-checked', true);
  6.         $formatted_date = date($date_format,$date);
  7.         $post_date = $_POST['wpcf-date-checked']['datetime'] . ' 00:00:00';
  8.         //Build the title & slug
  9.         $title = "Log Item". " ".$formatted_date." ".$_POST["wpcf-checked-by"];
  10.         $slug = sanitize_title($title);
  11.         // Update the post into the database
  12.         $my_post = array(
  13.             'ID' => $post_id,
  14.             'post_title' => $title,
  15.             'post_name' => $slug,
  16.             'post_date' => $post_date,
  17.             // 'post_date_gmt' => get_gmt_from_date( $date )
  18.         );
  19.         wp_update_post( $my_post );
  20.     }
  21. }
  22. add_action("cred_save_data","cred_nice_log_item_titles",10,2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement