Created
September 28, 2017 00:15
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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