Save something to global var in add_filter
Question
I am here again with a strange question.
First, I’m using ACF plugin for adding cistom fields. My code looks somethink like that:
global $testMe;
$testMe = 0;
function my_acf_update_value( $value, $post_id, $field ) {
global $testMe;
$testMe = $value;
return $value;
}
add_filter('acf/update_value/key=field_5308e5e79784b', 'my_acf_update_value', 10, 3);
echo $testMe; // -> print 0, not the $value!?
The problem is that I want, after the filter apply, $testMe to contain the value of $value.
Any ideas where I’m wrong?
0
advanced-custom-fields, filters, globals
9 years
2014-03-01T06:10:40-05:00
2014-03-01T06:10:40-05:00 0 Answers
75 views
0
Leave an answer