Auto assign author to new posts with wp_insert_post_data

to know if it’s a new post, you juste need to read the value of $postarr["ID"] :

$postType = "post";

add_filter("wp_insert_post_data" . $postType, function ($data, $postarr) {

    if (0 === $postarr["ID"]) { // it's a new post

        $data["post_author"] = 45;

    }


    return $data;


}, 10, 2);

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)