Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function my_pre_save_post( $post_id )
- {
- global $wpdb;
- $entered_title = $_POST['acf']['field_57dec9df66a5b'];
- $cleaned_title = preg_replace('/[^A-Za-z0-9\-\s]/', '', $entered_title); // Removes special chars.
- $post_name = sanitize_title($cleaned_title);
- // check if this is to be a new post
- if ( $post_id != 'new_post' )
- {
- // return $post_id;
- }
- $wpdb->update( $wpdb->posts, array( 'post_title' => $cleaned_title, 'post_name' => $post_name ), array( 'ID' => $post_id ) );
- update_field('field_57dec9df66a5b', $cleaned_title, $post_id);
- $to = get_option('admin_email');
- $subject = 'New submission';
- $message = 'This is the message body';
- $headers[] = 'From: Us <support@us.nl>';
- $headers[] = 'Content-Type: text/html; charset=UTF-8';
- // return the same ID
- return $post_id;
- }
- add_filter('acf/pre_save_post' , 'my_pre_save_post', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement