Skip to content

Instantly share code, notes, and snippets.

@cliffordp
Created September 28, 2017 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cliffordp/4d4875f93ee9acf08584007c978919a0 to your computer and use it in GitHub Desktop.
Save cliffordp/4d4875f93ee9acf08584007c978919a0 to your computer and use it in GitHub Desktop.
The Events Calendar: Event Aggregator: All imported events set to a specific user as the Post Author.
<?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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment