<?php
/**
* The Events Calendar: Event Aggregator: All imported events set to a specific
* user as the Post Author.
*
* Useful if all imported events are managed by a single WP User (e.g. verify
* and cleanup), particularly if managed via the Community Events "My Events"
* list of events.
*
* @link https://gist.github.com/cliffordp/4d4875f93ee9acf08584007c978919a0
*/
add_filter( 'tribe_aggregator_before_save_event', 'cliff_ea_set_author_for_imports', 10, 2 );
function cliff_ea_set_author_for_imports( $event, $record ) {
// !!! change to the User ID you want this to be !!!
$user_id_to_be_the_author = 4;
$user = get_userdata( $user_id_to_be_the_author );
if ( false !== $user ) {
$event['post_author'] = $user_id_to_be_the_author;
}
return $event;
}