I am working on cron job event to enable and disable wordpress automatic updates. I prepare cron job event and call this filter action auto_update_plugin but i couldn't properly called in functions.php. Cron job event succesfullly works but filter does not add_filter( 'auto_update_plugin' , '__return_true' , 10 , 2 ). If I use this filter out side the hook it works but inside the hook it does not work. ab_automatic_update_cron_true is a cron event which I am running. any help would be appreciated what I am wrong.
I want to enable and disable wordpress automatic updates. Do you have any suggestion or code please share it.
add_action( 'ab_automatic_update_cron_true', 'cw_true_function' , 10 , 2);
function cw_true_function() {
return add_filter( 'auto_update_plugin' , '__return_true' , 10 , 2 );
}