Support

Account

Home Forums General Issues Field last update date stamp? Reply To: Field last update date stamp?

  • Would this not be easier to have an extra text field with a custom date string in it that when the user submits the form you can use a combination of the pre_save_post filter along with the update_field() function to update this field, either to just include the default WordPress timestamp or to include your own?

    https://www.advancedcustomfields.com/resources/acf-pre_save_post/

    If there were other things going on on the page, or other acf form submissions that you didn’t want messing this up, you could specifically check to see if that field had been submitted by checking the post data to confirm that the name field had been changed:

    function my_pre_save_post( $post_id ) {
    
    	// in this example field_0987654321 is your name field and field_1234567890 is your date field 
    
    	if( $_POST['acf']['field_0987654321'] ) : 
    
    		// field_1234567890 needs to be the acf slug of the date field, not the field name
    	    update_field('field_1234567890', date('d/m/Y'), $post_id);
    
    	endif; 
    
    }
    
    add_filter('acf/pre_save_post' , 'my_pre_save_post', 10, 1 );

    Hope that helps? 🙂