Create WordPress User in backend, and automatically create a new post in Custom Post Type with user uame as the Title in the post

Modified your code above to post to the custom post type “Bookings,” set to draft, and use the user ID number as the post title. I also added a return value for the new post id so redirecting to that id or linking to it is much easier.

add_action( 'user_register', 'myplugin_registration_save', 10, 1 );

function myplugin_registration_save( $user_id ) {

        $userPostsCategory = 3;

        // Create post object
        $my_post = array(
          'post_title'    => $user_id,
          'post_content'  => 'You can edit this or create a new story',
          'post_type'     => 'Bookings',
          'post_status'   => 'draft',
          'post_author'   => $user_id
        );

        // Insert the post into the database and return new post id
        $itinerary_id = wp_insert_post( $my_post );
        return $itinerary_id;

}

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