Support

Account

Home Forums ACF PRO Set custom field to true for 4 categories upon save/update

Unread

Set custom field to true for 4 categories upon save/update

  • Hi,
    we have implemented a custom field with a true/false setting, however for 4 categories we want it to be set to true (1) upon saving the post. we thought to use the below code but it’s clearly not doing anything. can anyone help us out here ?

    function my_acf_update_value( $value, $post_id, $field ) {
        	if ( in_category('306') or in_category('39') or in_category('41')  or in_category('20') )  {
            $value = 1;
        }
        return $value;
    }
    add_filter('acf/update_value/name=fotos_zichtbaar', 'my_acf_update_value', 10, 3);
Viewing 1 post (of 1 total)

The topic ‘Set custom field to true for 4 categories upon save/update’ is closed to new replies.