Here is the link to do this, it’s look like i miss the ‘init’ hook.
https://support.advancedcustomfields.com/forums/topic/display-user-option-fields-on-left-side-bar/
Thanks, it work perfect!
Hi John,
i read about WP core and i found the way to help me do it.
Thank you for help!
Hello John,
I access to the dababase and find in column meta_value, i seem something like field_585d2d2af8d69. Are they field key?
Then i try edit your code and run test:
add_action('acf/save_post', 'my_acf_save_post', 1);
function my_acf_save_post()
{
// you need the field key of the field you want to check
$field_to_check_key = 'field_585d2d2af8d69';
var_dump($field_to_check_key);
$old_value = get_field('luc_nham_0_can', 339, false); // 339 is curent post ID
var_dump($old_value);
// see if it is different than new value
// also make sure the field key is set
if (isset($_POST['acf'][$field_to_check_key]) &&
$old_value != $_POST['acf'][$field_to_check_key])
{
echo 'Hello the Wolrd'; // Test if the field has changed.
}
// Test current fields
$curent_field = get_field('luc_nham_0_can');
var_dump($curent_field);
}
// Shortcode to test
add_shortcode('tess', 'my_acf_save_post');
I try to change the testing field many time, but $old_value has updated same $curent_field, it not keep old value.
You can see some images in this comment.
Hello John,
I read the link but i do not really understand. My English is not good and i work with WP Just recently.
I try some like this:
function my_acf_save_post( $post_id ) {
// array of field values
$fields = $_POST['acf'];
// specific field value
$field = $_POST['acf']['luc_nham']; // 'luc_nham' is an array fields i need to get
}
add_action('acf/save_post', 'my_acf_save_post', 1);
function tess_fields()
{
$id = get_the_ID();
$fields = my_acf_save_post($id);
var_dump($fields);
}
add_shortcode('tess', 'tess_fields');
Then i try to edit some fileds in a post, but alway return null. I dont know exactly i need to do. Can you help me an clearn example.
Many thanks!
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.