Home › Forums › Backend Issues (wp-admin) › Add into admin column for post number's of updated from ACF Select Box › Reply To: Add into admin column for post number's of updated from ACF Select Box
Hi @debosseta
If you want to use post revision, I suggest you get in touch with WordPress community instead for better support.
Another method would be using a number field that will hold the total count. Then you can update the total count by using the acf/save_post
hook like this:
function my_acf_save_post( $post_id ) {
if( get_post_type($post_id) == 'orders' ){
// Set the required field name and keys
$select_field_name = 'select_field_name';
$select_field_key = 'field_1234567890abc';
$number_field_name = 'number_field_name';
$number_field_key = 'field_abcdefghij123';
// Get the old data from database and the new data (posted data)
$old_select_value = get_field($select_field_name, $post_id);
$new_select_value = $_POST[$select_field_key];
// If the value changed
if( $old_select_value != $new_select_value ){
// Get the total count from the database
$old_count = get_field($number_field_name, $post_id);
// Change the posted data to make sure it's correct
// This will be saved automatically later
$_POST[$number_field_key] = $old_count + 1;
}
}
}
// run before ACF saves the $_POST['acf'] data
add_action('acf/save_post', 'my_acf_save_post', 1);
You can also disable the field by using CSS so the value can’t be edited from the backend.
If you want to have timestamps, I suggest you use the repeater field instead.
I hope this 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.