Sorry The end is missing.
The full code below works for me from admin:
function allowCoursesAuthorEditing()
{
if(current_user_can('administrator')){
add_post_type_support( 'courses', 'author' );
}
}
add_action('init','allowCoursesAuthorEditing');
function coursesAuthor($data , $postarr){
global $wpdb;
$courses_post_type = 'courses'; // type of custom post type tutor course
$post_ID = $postarr['ID']; // ID OF POST
$post_author = $postarr['post_author']; POST TYPE
if ($data['post_type'] === $courses_post_type){
if ($post_author > 0){
$data['post_author'] = $post_author;
}else{
$data['post_author'] = get_current_user_id();
}
}
return $data;
}
add_filter('wp_insert_post_data', 'coursesAuthor', '99', 2);