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? 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.