Hi @wpwhitesecurity
Thank you for your reply!
and sorry for my bad explanation.
I am running a cronjob (wp-cron) which does bluk delete using ‘wp_delete_post’.
It deletes 100 and more posts at once,
then all the ‘delete_post_meta’ logs are recorded by WSAL.
But each post have nearly 50 post metas,
so I wanna stop WSAL recording logs for deleting postmeta while cronjob is working.
I’ve tried these below.
but they did not work.
Pattern A -> not work
add_action('init', 'stop_WSAL_for_cronjob', 1000);
function stop_WSAL_for_cronjob(){
if ( !defined( 'DOING_CRON' ) ){ return; }
remove_action('add_post_meta', array( WSAL_Sensors_MetaData::HookEvents(), 'EventPostMetaCreated' ), 10, 3);
remove_action('update_post_meta', array( WSAL_Sensors_MetaData::HookEvents(), 'EventPostMetaUpdating' ), 10, 3);
remove_action('updated_post_meta', array( WSAL_Sensors_MetaData::HookEvents(), 'EventPostMetaUpdated'), 10, 4);
remove_action('deleted_post_meta', array( WSAL_Sensors_MetaData::HookEvents(), 'EventPostMetaDeleted'), 10, 4);
}
Pattern B -> not work
add_action('init', 'stop_WSAL_for_cronjob', 1000);
function stop_WSAL_for_cronjob(){
if ( !defined( 'DOING_CRON' ) ){ return; }
remove_action('add_post_meta', array( WpSecurityAuditLog::GetInstance()->sensors->HookEvents(), 'EventPostMetaCreated' ), 10, 3);
remove_action('update_post_meta', array( WpSecurityAuditLog::GetInstance()->sensors->HookEvents(), 'EventPostMetaUpdating' ), 10, 3);
remove_action('updated_post_meta', array( WpSecurityAuditLog::GetInstance()->sensors->HookEvents(), 'EventPostMetaUpdated'), 10, 4);
remove_action('deleted_post_meta', array( WpSecurityAuditLog::GetInstance()->sensors->HookEvents(), 'EventPostMetaDeleted'), 10, 4);
}
I want to know the right way to remove_action().