To make the clean up code stream specific you need to filter the query by asset. By default fields have an asset of profile.USER_ID.field.FIELD_ID. Lets assume your fields ID is 10. Now we need this to apply to every profile for that field and that's done using a wildcard. So you'd have profile.%.field.10. This is then applied to the query using a LIKE operator. Next it should be slimmed down for CB Auto Actions purpose as follows.
Code:
global $_CB_database;
$asset = 'profile.%.field.10';
$duration = '-3 DAYS';
$query = 'SELECT *'
. "\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_activity' )
. "\n WHERE " . $_CB_database->NameQuote( 'asset' ) . " LIKE " . $_CB_database->Quote( $asset );
. "\n AND " . $_CB_database->NameQuote( 'date' ) . " <= " . $_CB_database->Quote( \CBLib\Application\Application::Date( 'now', 'UTC' )->modify( $duration )->format( 'Y-m-d H:i:s' ) );
$_CB_database->setQuery( $query );
$activities = $_CB_database->loadObjectList( null, '\CB\Plugin\Activity\Table\ActivityTable', array( $_CB_database ) );
foreach ( $activities as $activity ) {
$activity->delete();
}
Adjust $asset and $duration as needed. For example if your field id isn't 10 change that in the asset. If you want it to delete things older than 5 days instead of 3 then set duration to -5 DAYS.