Support

Account

Home Forums Backend Issues (wp-admin) Why isn't acf/save_post firing? Reply To: Why isn't acf/save_post firing?

  • Yes, of course. Here is the function code:

    	function send_checklist_publish( $new_status, $old_status, $post )
    	{
    	    if ( 'publish' !== $new_status
    	        or 'checklist' !== get_post_type( $post ) )
    	        return;
    	
    
    				$post_type = get_post_type( $post ); //get post type
    
    				$titles = new WP_Query(array('post_type' => $post_type, 'p' => $post->ID));
    				$titles->the_post();
    				$categories = get_the_category();
    				$category = $categories[0]->name;
    				$response = get_the_terms( $post->ID, 'Response_Category' );
    				$problematic = get_field('would_you_consider_this_film_problematic');
                    $subject_line = $_POST['fields']['subject_line'];
    				if($problematic == 'Yes'):
    					$problematic_response = "*Be advised upon ingest, it was recognized that this title is problematic.* <br/><br/>";
    				endif;
    
    				//Get Author's Name
    				$userID =  get_the_author_id();
    				$user_info = get_userdata( $userID );
    				$first_name = $user_info->first_name;
    				$last_name = $user_info->last_name;
    
    				if($response[0]->slug == "send-check-list-email"){ //Send email if checked
    
    			        $lists = array(...); // This is an array of all of our email addresses. Pulled to avoid spam, and already verified this is not the code causing the issue.
    
    				$email = array();
    				$terms = get_the_terms( $post->ID, 'Distro_Category' );
    				foreach ( $terms as $term ) {
    
    				if (array_key_exists($term->name,$lists))
    				   {
    				  	$term_name = $term->name;
    
    					$i = 0;
    					foreach($lists[$term_name] as $list){ //Loop through users on the Distro List
    
    					$getUser = get_user_by( 'email', $list );
    					$networks = get_user_meta( $getUser->ID, 'networks', true );
    
    					if(in_array($category,$networks)){
    						$emails[] = $list;
    						}
    
    							$i++;
    				   	 }  //End foreach
    
    				   } 
    
    				}
    
    				$postid = get_the_ID();
    				//$postid = 30104;
    				
    
    				$body =  'Hello:
    
    				<br/><br/>
    
    				'.get_the_title().' has been ingested and placed in ISIS. You can view the checklist here:
    				<br/><br/>
    
    				<a href='.get_permalink($post->ID).'>'.get_permalink($post->ID).'</a>
    				<br/><br/>
    				
    				'.$problematic_response.'
    			
    				Thank You, <br/>
    				'.$first_name.' '.$last_name.' <br/>
    				Ingest Ops';
    
    				//Email Headers
    				$headers = "From:  Network Database <[email protected]>";
    
                    wp_mail( $emails, $subject_line . ': '.get_the_title().'', $body, $headers );
    
    				} 
    
    	}

    Also, I don’t mind adding the update_field function in to test, but since both add_actions are calling the same function (send_checklist_publish), wouldn’t it be correct to believe that the acf/save_post hook isn’t getting fired since it doesn’t send out an email when the transition_post_status does send out an email? Or is there something I’m missing.

    Thanks!